Need Help - code needs to display a message if file is not in directory

qwalk300

New Member
DEFINE VARIABLE ch-File-Info AS CHARACTER EXTENT 3 NO-UNDO.
See code below.
The below code will look in my directory and disp message 'file received' if there is a *.diff* file in my directory, however when I do not have a .diff file in my directory the code displays nothing. I need it to display 'File Not Received' when there is not that type of file in my directory. Please help!

INPUT STREAM file FROM OS-DIR("/x/see/") no-echo.
REPEAT:
IMPORT STREAM file ch-File-Info.
IF ch-File-Info[3] NE "F" THEN NEXT.
IF (ch-File-Info[1] matches "*.diff*") = false THEN NEXT.
DO.
IF ch-File-Info[1] <> "" THEN
Message "File Received".
ELSE
Message 'File not received'.
END.
END.
 
If you adjust your code to something similar to the following it should display the message that the file is not received:

Code:
DEFINE VARIABLE ch-File-Info AS CHARACTER EXTENT 3 NO-UNDO.
DEFINE VARIABLE ch-File-Received AS LOGICAL INITIAL NO NO-UNDO.
 
DEF STREAM file.
 
INPUT STREAM file FROM OS-DIR("/x/see/") no-echo.
REPEAT:
   IMPORT STREAM file ch-File-Info.
   IF ch-File-Info[3] NE "F" THEN NEXT.
   IF (ch-File-Info[1] matches "*.diff*") = false THEN NEXT.
   IF ch-File-Info[1] <> "" THEN DO:
      ch-File-Received = YES.
      LEAVE.
   END.
END.
INPUT STREAM file CLOSE.
IF ch-File-Received THEN
   Message "File Received".
ELSE
   Message 'File not received'.
 
The propath may contain many directories and to read each one:
Code:
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE vFileDirName AS CHARACTER NO-UNDO.
 
REPEAT i = 1 TO NUM-ENTRIES(PROPATH):
   ASSIGN vFileDirName = ENTRY(i , PROPATH)
          FILE-INFO:FILE-NAME = vFileDirName.
   IF FILE-INFO:FILE-TYPE = "DRW" THEN DO: /* Directory */
      vFileDirName = FILE-INFO:FULL-PATHNAME.
      INPUT STREAM file FROM OS-DIR(vFileDirName) no-echo.
      REPEAT:
         IMPORT STREAM file ch-File-Info.
         /* Actions */
      END.
      INPUT STREAM file CLOSE.
   END.
END.
 
Back
Top