Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CBL_CHECK_FILE_EXIST always returning 0

Status
Not open for further replies.

hans1

Programmer
Jul 2, 2003
1
0
0
DK
I have a big problem in Fujitsu COBOL V7. When using the CBL_CHECK_FILE_EXIST routine to see if a file exists I always gets return-code 0.
How can I see if a file exists or not?
 
You can use "GetFileAttributesA" (attributes of a file it's better than check_file_exist because is very short) if the file exist return-value is 0 else -1 you need use kernel32.lib.

On cbl routines routine check_file_exist is wrong, you can retrieve the correct file on support fujitsu.
************
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 COMODI.
03 W-CHAR PIC X VALUE X"00".
03 FILENAME PIC X(256).
03 RETURN-VALUE PIC S9(9) COMP-5.
PROCEDURE DIVISION.
CHECK-FILE-EXIST.
MOVE SPACE TO FILENAME
STRING
"\daca\ark\ARKDIT" DELIMITED BY SIZE
W-CHAR DELIMITED BY SIZE
INTO FILENAME
***************************
CALL "GetFileAttributesA" WITH STDCALL USING
BY REFERENCE FILENAME
RETURNING RETURN-VALUE
END-CALL.
********************
ERRORI.
IF RETURN-VALUE NOT = -1
GO TO CHECK1
ELSE

OPEN OUTPUT ARKDIT
MOVE SPACE TO RECD
WRITE RECD
CLOSE ARKDIT
GO TO CHECK1

END-IF.

CHECK1.
GO TO FINE.

FINE.
EXIT PROGRAM.
*******************
fsccdm
 
You are correct that the CBL_CHECK_FILE_EXIST always returns a zero. It was that way in previous releases as well. You can check the File-Size return by this call for less than one. If the file size is less than 1 you can assume the file does not exist. The previous responce is also a good work around.
 
There was also an "undocumented feature" in the CBL_ routines. Fujitsu released a new DLL which is available to on their Support Web Site for clients with maintenance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top