Consultor Eletrônico



Kbase P19552: How to use OS-DIR?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2008
Status: Verified

GOAL:

How to use OS-DIR?

GOAL:

How to select specific files based on extension when using OS-DIR?

FIX:

Use the following code to select specific files (based on file extension) when reading files using OS-DIR:

DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFullFileName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFileType AS CHARACTER NO-UNDO.
DEFINE VARIABLE cExt AS CHARACTER NO-UNDO.

INPUT FROM OS-DIR(".").

REPEAT:
IMPORT cFileName cFullFileName cFileType.
IF cFileType = "F" THEN
DO:
ASSIGN cExt = TRIM(SUBSTRING(cFileName,R-INDEX(cFileName,'.'),-1)).
IF cExt = ".p" OR cExt = ".w" THEN /* Extensions Go Here */
/* Code Goes Here To Process Selected Files */
END.