You generally use the INPUT FROM statement to read the contents of an operating system file; however, you can also read a list of the files in a directory using the OS-DIR option of the INPUT FROM statement. The INPUT FROM statement specifies a new input source. Using INPUT FROM OS-DIR indicates that you want your input to be the filenames found in the directory you specify. If that directory is not a valid directory or you do not have permission to read it, an error condition occurs. Otherwise, OpenEdge generates the directory list and sends it to the calling program through the INPUT stream. An INPUT CLOSE statement discards any unread filenames from the list.
The following example uses the OS-GETENV function to find the path of the DLC directory, then uses the OS-DIR option of INPUT FROM to read the contents of the directory:
DEFINE VARIABLE search-dir AS CHARACTER.
DEFINE VARIABLE file-name AS CHARACTER FORMAT "x(25)" LABEL "File".
DEFINE VARIABLE attr-list AS CHARACTER FORMAT "x(4)" LABEL "Attributes".
search-dir = OS-GETENV("DLC").
INPUT FROM OS-DIR(search-dir).
REPEAT:
SET file-name ^ attr-list
WITH WIDTH 70 USE-TEXT TITLE "Contents of " + search-dir.
END.
INPUT CLOSE.
When you use the OS-DIR option, the UNBUFFERED option is ignored. OS-DIR always buffers exactly one filename at a time. When you try to read beyond the last filename in the list, OpenEdge generates the ENDKEY condition.
See OpenEdge Development: ABL Reference for more information on the INPUT FROM statement.