Kbase P125680: ABL/4GL: How to recursively list all directories on a given volume (drive)?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  27/05/2009 |
|
Status: Verified
GOAL:
ABL/4GL: How to recursively list all directories on a given volume (drive)?
GOAL:
How to find all subdirectories programmatically ?
FACT(s) (Environment):
Windows
Progress 8.x
Progress 9.x
OpenEdge 10.x
OpenEdge Category: Language (4GL/ABL)
FIX:
The following code generates a report listing all the directories on a given drive starting from the initial directory "C:\Progress\".
DEFINE VARIABLE cCurrentDirectory AS CHARACTER NO-UNDO.
ASSIGN
cCurrentDirectory = "C:\Progress\".
/* Note: the trailing backslash is needed */
OUTPUT TO ttDirectoryTree.txt.
RUN getChildren(INPUT cCurrentDirectory).
OUTPUT CLOSE.
PROCEDURE getChildren:
DEFINE INPUT PARAMETER ipcCurrentDirectory AS CHARACTER.
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
INPUT FROM OS-DIR (ipcCurrentDirectory).
REPEAT:
IMPORT cFileName.
IF cFileName = '.' OR cFileName = '..' OR cFileName = ? THEN NEXT.
FILE-INFO:FILE-NAME = ipcCurrentDirectory + cFileName.
IF NOT FILE-INFO:FILE-TYPE BEGINS "D" THEN NEXT.
IF FILE-INFO:FULL-PATHNAME <> ? THEN DO:
PUT UNFORMATTED FILE-INFO:FULL-PATHNAME SKIP.
RUN getChildren(INPUT FILE-INFO:FULL-PATHNAME + "\").
END.
END.
END.