Hi
I want to open a file that does not exist as a LOG file.
In my program I dont know if the file was created before
and i want to know if there is a way to verify that the file exist or not.
if not then to open it for the first time as output.
INIT.
OPEN I-O NAME-FILE
IF NAME-FILE-STATUS IS NOT EQUAL TO ZERO
OPEN OUTPUT NAME-FILE
PERFORM INIT-CHK-FILE-STATUS
CLOSE NAME-FILE
PERFORM INIT-CHK-FILE-STATUS
OPEN I-O NAME-FILE
PERFORM INIT-CHK-FILE-STATUS
END-IF
That is for indexed files. By opening it, you get yes or no a problem with the file status. If yes, you open for output, else you open EXTEND. I am not sure, but I even think that if you open EXTEND the file doesn't need to be there before. If you open the file without a problem, you know it exists.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.