![]() |
Software > OpenVMS Systems > Ask the Wizard ![]() HP OpenVMS Systemsask the wizard |
![]() |
The Question is: I am using the F$SEARCH command to define a symbol for a input file name that will be used in a Cobol program as an input file Example: load_product_file == f$search("TELE$DATA:ACCOUNTPRODUCT_*SMS.TXT") A new file can be posted (using the same name) several times before my command procedure runs in the batch queue. So the target directory will contain multiple versions of the same file name but with different version numbers. Is there anyway I can make the F$SEARCH smart enough to capture the oldest file?? Currently, the F$SEARCH command captures the files from the most recent to the oldest (3,2,1). I would like F$SEARCH to find the oldest file in the directory. Thereby allowi ng the command file to process the files in order of creation(1,2,3). Can it be done? The Answer is : Version number ";-0" is defined to be the lowest version number. So the assignment: $ load_product_file == f$search("TELE$DATA:ACCOUNTPRODUCT_*SMS.TXT;-0") will find the oldest version of the first file that matches the filename wildcard. There is no syntax for finding the *second* oldest file. You can find the second and subsequent *youngest* files using version numbers ";-1", ";-2",... To work through a list of files in creation order by version number, the simplest method would be to RENAME or DELETE the files after they've been processed, and use the ";-0" syntax to find the next file. For example: $ FileLoop: $ nextfile=F$SEARCH("WAITING_DIRECTORY:SOMEFILE.DAT;-0") $ IF nextfile.EQS."" THEN GOTO NoMore $ PROCESS 'nextfile' $ RENAME 'nextfile' COMPLETED_DIRECTORY: $ GOTO FileLoop $ NoMore:
|