Stephen,Actually, what you are looking for is fairly simple.
If I understand you correctly, you are seeking the same basic functionality that is used to list files by the DIRECTORY command. For example, the DIRECTORY command to list all executable binary files on a disk would be DIRECTORY devicename:[000000...]*.EXE. The "000000" is a reference to the MFD (Master File Directory) which is the root of the directory structure on a file-structured volume.
The iterative search functionality is actually a part of RMS, the Record Management System. From DCL, it can be accessed using the F$SEARCH lexical function, as illustrated by the following small code segment that iteratively scans for all executable files on volume DKA200:
$ TOP: FILENAME = F$SEARCH("DKA200:[000000...]*.EXE")
$ IF F$LENGTH(FILENAME) .EQ. 0 THEN EXIT
$ WRITE SYS$OUTPUT FILENAME
$ GOTO TOP
While it is guaranteed that every executable file will show up at least once, it is also possible to see files more than once, because of the possibility of alias entries for directories.
When the search is complete, the result of FF$SEARCH will be an empty string.
Since you get the filenames back one filename at a time, there is a good chance that you will not need an intermediate file.
You may also find my presentation on DCL lexical functions from the 1995 San Francisco DECUS User's symposium, "DCL Lexicals: OpenVMS Jujitsu", useful. The slides from that session can be found at:
http://www.rlgsc.com/decus/usf95/index.html
- Bob Gezelter, http://www.rlgsc.com