Skip to content

LF API

Release Date: 9/7/2021

Versions: 8.0 and higher

This API takes a filespec, like C:\WINDOWS\*.*, and returns the next file in the specified directory for each successive call. 

Screen Parameters

Comment

LF,nn

Input:

SCREEN-LITERAL contains the filespec, with wildcards, that will be used for returning matching files.

Output:

SCREEN-ALPHA-FIELD:

contains .the next matching file in the directory, without the directory name.  If there is no more matching file, SCREEN-ALPHA-FIELD will return SPACES.

SCREEN-NUMERIC-FIELD:

contains the size, in bytes, of the returned file.

 

Whenever SCREEN-LITERAL changes, the search will begin again at the beginning of the directory.

 

Nn=99 means terminate the search; even if the next call has the same value in SCREEN-LITERAL as the previous call, the file returned after the nn=99 call will be the first matching file in the directory.

 Example:

      *> Make sure any prior LF sequence is terminated...
        MOVE "LF,99" TO SCREEN-PARAMETERS
        PERFORM SCREEN-ROUTINE
 
      *> Get the first matching file...
        MOVE "LF" TO SCREEN-ROUTINE
        MOVE "C:\WINDOWS\*.*" TO SCREEN-LITERAL
        PERFORM SCREEN-ROUTINE

      *> Process each file until there are no more...
        PERFORM UNTIL SCREEN-ALPHA-FIELD = SPACES
            PERFORM PROCESS-ONE-FILE
            PERFORM SCREEN-ROUTINE
        END-PERFORM

Note: The program called by this API is used both on the application side and on the system side.  Application-side LF processing loops are protected from system-side LF-like processing loops -- i.e., the application-side LF loop will not be interrupted by any system-side LF-like processing.  However, multiple application-side LF loops will interfere with each other.  Therefore, while your code is in an LF processing loop, make sure there is no downstream application code that uses the LF API.

JEG

Feedback and Knowledge Base