Problem:
How to search for files with a certain extension (e.g. *.cbl) in a directory using a Cobol program.
Resolution:
Use the X'91' function 69 routine. A loop can be used to retrieve many matched files as shown in the excerpt of code below:
[...]
move 'd:\\dir\\*.cbl' to f-filein
move spaces to f-fileout
call x'91' using f-result,
function-code, *>69
f-parameters.
move 1 to f-action
perform search-files until f-error = 1 or 2
[...]
search-files.
if f-attrout >= 32
display f-fileout
end-if
move spaces f-fileout
call x'91' using f-result,
function-code, *>69
f-parameters
.
[...]
Note: If the file's attribute Archive has been cleared, the value of f-attrout would be zero. This could be something to be considered as a backup software could turn this option off.