unable to access files (SOLVED: blank spaced Dir name)

I'm using Visual Studio 2019 Visual Cobol and I have problems accessing sequential files. When I try in the program to open a  Sequential/line sequential files, with variable record length, the data accessed is not from the opened file but of another file created in previous runs. They are like ghost files. So there is no way I can access existing sequential files. Also, I created sequential files under VS, using internal data and it works fine, but then these files cannot be accessed (file not found) by another external program.

 

Jan 26, 2021: PROBLEM SOLVED thanks to the help of this Community's users.

 Origin: Use of Spaced Directory names(Windows platform).

 Two solutions:

1- Do not use blank spaced Directory names,  e.g:   NO:   "D:\File1  part1\......\filename".  (blank spaced)

                                                                                                       YES: "D:\File1part1\......\filename". (No blank spaced)

 2- USE blank spaced Directory names, but add extra single quotes:

                             YES: ' "D:\File1  part1\......\filename" '. (blank spaced Dir and  extra single

                                                                                                                            quotes)

  • Verified Answer

    From the screenshot Notepad appears to be open a file without the .txt extension and the program is opening a file with the .txt extension.

    Do you perhaps have 2 versions of this file in your folder?

  • Notepad doesn't show the file type, just the filename. Regards.

  • Forgot to add that there are no duplicate files, also I have tried with different files form different directories. Regards.

  • See if this file with the "ghost data" exists anywhere else on your system.
  • No. I did an extensive search through all the directories but couldn't
    find it.
    As I mentioned before, the displayed data is of a file I created from a VS
    Cobol program.No matter Input file I use, the same data is displayed/get.
    Regards.



  • Sorry was behind in the post.  So in looking at the full program, that program did not produce the output you attached.  The program you attached does a stop 666 after each read and then does a goback so at most it will read and display one record.  Perhaps upload the actual COBOL code to and the actual datafile to this thread.  

    The other things, if at all possible can you move the datafile to a directory structure without spaces in the name. change your code and see if that helps.

    Last question, was the input file created by another program or did you manually create it?

     

  • 99% sure It's the spaces in the directory name that are killing you.  See if there isn't a file called NEW in the directory D:\PROJCOBOL\WORKAREA\ and if it doesn't match the displays

  • Hi to all:
    My problem was SOLVED, as suggested, by NOT using multi-word DIR names (e.g
    TESTFILE and not TEST FILE). I am attaching the image of the failed Run
    display (with Ghost data) using blank spaced directory name
    ("D:\PROJCOBOL\WORKAREA\*NEW PROJ 2020*\TERMNOTEPADHAND.TXT"), and the
    image of the Not-failed run display using non-spaced Dir name (
    ("D:\PROJCOBOL\WORKAREA\*NEWPROJ2020*\TERMNOTEPADHAND.TXT"), In my previous
    sample program, I was reading just 1 record and using the STOP xxxx command
    in order to watch the data displayed on the screen.
    Thanks to you all for the help. Regards.

    Note: The first line of the Displays shows the full access path of the file.
  • SteveW2:

    As I mention in my last Post, you were right regarding spaced Dir names:  the problem was fixed not using multi-word Dir names. Here attach copy of my Cobol test program, the file used for testing, and the  images of the output displays with blank-spaced and non-blank spaced Dir names. Still Unresolved the origin of the Ghost file data. I used Comment line to switch file's path.

                              REGARDS

    -------

    IDENTIFICATION DIVISION.
    PROGRAM-ID. FILETEST1.
    ENVIRONMENT DIVISION.
    INPUT-OUTPUT SECTION.
    FILE-CONTROL.
    SELECT TEST-FILE3 ASSIGN TO TESTFILE-DSNAME
    ORGANIZATION LINE SEQUENTIAL  ACCESS MODE IS SEQUENTIAL
    FILE STATUS IS FILE1-STATUS.

    DATA DIVISION.
    FILE SECTION.
    FD TEST-FILE3 RECORD VARYING FROM 1 TO 500
    DEPENDING ON WS-CURRENT-RECL.

    01 ZAP005D1-REC.
    02 TERM1-REC PIC X(458).
    02 TERM2-REC PIC 9(2).

    WORKING-STORAGE SECTION.
    77 WS-CURRENT-RECL PIC 9(4) COMP VALUE 0.
    01 FILE1-STATUS.
    05 FILE1A-STATUS PIC X.
    05 FILE1B-STATUS PIC X.

    **** FILE' FULL PATH *********************************

    01 TESTFILE-DSNAME PIC X(80) VALUE

    ***** "D:\PROJCOBOL\WORKAREA\NEW PROJ 2020\TERMNOTEPADHAND.TXT". *>FAIL
    "D:\PROJCOBOL\WORKAREA\NEWPROJ2020\TERMNOTEPADHAND.TXT".  *> OK

    PROCEDURE DIVISION.
    DISPLAY " "
    DISPLAY "***INPUT FILE FULL PATH.->" TESTFILE-DSNAME
    OPEN INPUT TEST-FILE3
    DISPLAY "OPENING.FILE STATUS->" FILE1A-STATUS  "/"  FILE1B-STATUS

    IF FILE1-STATUS NOT = ZERO
         DISPLAY "..ERROR OPENING.FILE STATUS->" FILE1-STATUS
        GOBACK
    END-IF
    ****

    PERFORM 5 TIMES
    READ TEST-FILE3

             AT END DISPLAY "..END OF TESTFILE1"
                    STOP 999
                 GOBACK
            NOT AT END
                     DISPLAY  "/RECORD->"  ZAP005D1-REC(1:WS-CURRENT-RECL)
                    "/RECL->" WS-CURRENT-RECL  "/FS AFTER READ->"   FILE1-STATUS
     END-READ

    END-PERFORM

    CLOSE TEST-FILE3

    STOP 888
    GOBACK.

    END PROGRAM FILETEST1.

  • How was the input file originally created? Was they a program that wrote it out?  In this directory D:\PROJCOBOL\WORKAREA, is there a file called NEW?  If so when you edit it, does it match the ghost data?  I'm guessing it does.