The Question is:
I am trying to obtain information about files in a directory with a view to
deleting them, but need to do this within a COBOL program. Are there any
examples on equivalent COBOL calls to f$search and delete in DCL?
The Answer is :
lib$find_file and lib$delete_file would be the calls involved.
Attached is an example of these calls from within a COBOL program.
01 answer pic x.
01 file-spec pic x(7) value '*.tmp;*'.
01 result-spec pic x(255) value spaces.
01 context pic 9(5) comp value zero.
01 stat pic s9(9) comp value zero.
01 counter pic s9(9) comp value zero.
01 rms$_nmf pic s9(9) comp value external rms$_nmf.
01 rms$_normal pic s9(9) comp value external rms$_normal.
move "N" to answer.
call 'lib$find_file' using by descriptor file-spec
by descriptor result-spec
by reference context
omitted omitted omitted
if stat = rms$_nmf then go to fini.
display "Delete? " with no advancing.
if answer = "y" then move "Y" to answer.
if answer not equal "Y" then go to loop.
call 'lib$delete_file' using by descriptor file-spec giving stat.
if stat = rms$_normal then go to loop.
display "Delete status = ", stat with conversion.
go to loop.
call 'lib$find_file_end' using by reference context.