Progress
Programming
Handbook
Reading the Contents of a Directory
Sometimes, rather than reading the contents of a file, you want to read a list of the files in a directory. You can use the OS–DIR option of the INPUT FROM statement for this purpose.
Each line read from OS–DIR contains three values:
The tokens are returned in the standard Progress format that can be read by the IMPORT or SET statements.
The following example uses the OS–GETENV function to find the path of the DLC directory. It then uses the OS–DIR option of INPUT FROM to read the contents of the directory:
In
p-osdir.p
, only the base name of the file and attribute string are read from OS–DIR. The caret (^) is used in the SET statement to skip over the pathname of the file.For more information on the OS–DIR option, see the INPUT FROM Statement reference entry in the Progress Language Reference .
You can find additional information on a single file by using the FILE–INFO system handle. To use the FILE–INFO handle, first assign the pathname of an operating system file to the FILE–INFO:FILE–NAME attribute. You can then read other FILE–INFO attributes. For example, the
p-osfile.p
procedure prompts for the pathname of a file and then uses the FILE–INFO handle to get information on that file:
For more information, see the FILE–INFO System Handle reference entry in the Progress Language Reference .
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |