COBOL How to delete a file?
Posted: Sat Feb 04, 2023 10:23 am
How to delete a file in COBOL?
/Fim W
/Fim W
The official board to discuss OpenVMS-related topics
https://forum.vmssoftware.com/
Code: Select all
> How to delete a file in COBOL?
Never having written a COBOL program, I know nothing, but the "VSI
COBOL for OpenVMS User Manual"
( https://docs.vmssoftware.com/docs/vsi-cobol-for-openvms-user-guide.pdf )
Section 8.3.2, "Using File Protection" says:
o DELETE--Permits deletion of the file and is therefore not applicable
to a VSI COBOL program (since VSI COBOL has no delete file facility)
except through system service routines.
I also don't know the best way to delete a file using (RMS) system
services, but I'd guess that you could use $OPEN to open the file, set
the FAB$V_DLT bit in the FAB, and then use $CLOSE to close/delete it.
(Fortran CLOSE has a DISPOSE=DELETE option to do this, for example,
which makes it sound to me as if CLOSE is a popular place to do this
kind of thing.)
Or, perhaps easier, LIB$DELETE_FILE.
HELP RTL_ROUTINES LIB$ LIB$DELETE_FILE
Chapter 13, "Using VSI COBOL in the Alpha or VAX Common Language
Environment" in the User Manual seems to deal with (Section 13.4)
"Calling Routines".
To me, it all looks like even less fun than pure COBOL, but there are
some examples in the User Manual.