Consultor Eletrônico



Kbase P17784: How to programmatically read the contents of a directory
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/25/2006
Status: Verified

GOAL:

How to programmatically read the contents of a directory

FIX:

/*example p-osdir.p */
DEFINE VARIABLE search-dir AS CHARACTER FORMAT "x(77)" LABEL "SEARCH - DIRECTORY" .
DEFINE VARIABLE file-name AS CHARACTER FORMAT "x(77)" LABEL "File".
DEFINE VARIABLE attr-list AS CHARACTER FORMAT "x(4)" LABEL "Attributes".
/* searches by default the current directory */
search-dir = ".".
UPDATE search-dir.
INPUT FROM OS-DIR(search-dir).
REPEAT:
SET file-name ^ attr-list
WITH WIDTH 79 USE-TEXT TITLE "Contents of " + search-dir.
END.
INPUT CLOSE.