home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / filerx11.zip / MATCH.CMD < prev    next >
OS/2 REXX Batch file  |  1995-02-10  |  4KB  |  154 lines

  1. /******************************************************************
  2.  * MATCH.CMD
  3.  *
  4.  * This program calls the various REXX external functions provided in the FILEREXX DLL.
  5.  *******************************************************************/
  6.  
  7.  
  8. /* The FileLoadFuncs loads all the rest of the REXX functions in the FILEREXX DLL. */
  9. /* So, we don't have to make calls to RxFuncAdd to add each one of those functions. Of */
  10. /* course, in order to call FileLoadFuncs, we have to add that one. */
  11. CALL RxFuncAdd 'FileLoadFuncs', 'FILEREXX', 'FileLoadFuncs'
  12. CALL FileLoadFuncs
  13.  
  14.  
  15.  
  16.  
  17. /* ============================ FileDriveMap ============================ */
  18. /* Get list of all used drives */
  19. err = FileDriveMap()
  20. SAY  "FileDriveMap() =" err
  21.  
  22.  
  23.  
  24. /* ============================ FileDriveInfo ============================ */
  25. /* Get info about current drive */
  26. err = FileDevInfo('Info')
  27. IF err = 0 THEN DO
  28.     SAY 'Bytes Free =' Info.0
  29.     SAY 'Bytes Used =' Info.1
  30.     SAY 'Serial Number =' Info.2
  31.     SAY 'Volume Label =' Info.3
  32.     SAY 'Current drive =' Info
  33. END
  34. ELSE SAY  "FileDevInfo('Info') =" err
  35.  
  36.  
  37.  
  38.  
  39. /* =========================== FileMatchFile ============================ */
  40. /* Initially set handle to 0 */
  41. Handle = 0
  42.  
  43. SAY 'Searching for *.cmd'
  44.  
  45. /* Search for a match to '*.cmd' in current directory. Only check read/write files */
  46. DO UNTIL Handle = 0
  47.     err = FileMatchFile('File', 'Handle', '*.cmd',, 'SIZE|DATE')
  48.  
  49.     /* No error (ie, another match?) */
  50.     IF err = 0 THEN DO
  51.  
  52.     /* Print filename */
  53.     SAY File '|' File.0 '|' File.1
  54.  
  55.     END
  56.  
  57.     /* An error occurred */
  58.     ELSE IF err <> 18 THEN SAY "FileMatchFile('File', 'Handle', '*.cmd',, 'SIZE|DATE') =" err
  59. END
  60.  
  61.  
  62.  
  63.  
  64. /* =========================== FileMatchFile ============================ */
  65. /* Initially set handle to 0 */
  66. Handle = 0
  67.  
  68. SAY 'Searching for directories in current directory'
  69.  
  70. /* Search for a match to '*.*' in current directory. Only check subdirectories */
  71. DO UNTIL Handle = 0
  72.     err = FileMatchFile('File', 'Handle',, 'DIRONLY')
  73.  
  74.     /* No error (ie, another match?) */
  75.     IF err = 0 THEN DO
  76.  
  77.     /* Print filename */
  78.     SAY File
  79.  
  80.     END
  81.  
  82.     /* An error occurred */
  83.     ELSE IF err <> 18 THEN SAY    "FileMatchFile('File', 'Handle',, 'DIRONLY') =" err
  84. END
  85.  
  86.  
  87.  
  88.  
  89. /* =========================== FileMatchFile ============================ */
  90. /* Initially set handle to 0 */
  91. Handle = 0
  92.  
  93. SAY 'Searching for directories in C:\OS2\'
  94.  
  95. /* Search for a match to '*.*' in C:\OS2. Only check subdirectories */
  96. DO UNTIL Handle = 0
  97.     err = FileMatchFile('File', 'Handle', 'c:\os2\*.*', 'DIRONLY')
  98.  
  99.     /* No error (ie, another match?) */
  100.     IF err = 0 THEN DO
  101.  
  102.     /* Print filename */
  103.     SAY File
  104.  
  105.     END
  106.  
  107.     /* An error occurred */
  108.     ELSE IF err <> 18 THEN SAY "FileMatchFile('File', 'Handle', 'c:\os2\*.*', 'DIRONLY') =" err
  109. END
  110.  
  111.  
  112.  
  113. /* =========================== FileMatchFile ============================ */
  114. /* Initially set handle to 0 */
  115. Handle = 0
  116.  
  117. SAY 'Check for existance of match.cmd'
  118.  
  119. /* Search for a match to 'match.cmd' in current directory. Allow archived files,
  120.    readonly files, and dirs */
  121. DO UNTIL Handle = 0
  122.     err = FileMatchFile('File', 'Handle', 'match.cmd', 'DIR|ARC|RDO')
  123.  
  124.     /* No error (ie, another match?) */
  125.     IF err = 0 THEN DO
  126.  
  127.     /* Print filename */
  128.     SAY File
  129.  
  130.     END
  131.  
  132.     /* An error occurred */
  133.     ELSE IF err <> 18 THEN SAY    "FileMatchFile('File', 'Handle', 'match.cmd', 'DIR|ARC|RDO') =" err
  134. END
  135.  
  136.  
  137.  
  138.  
  139. /* An easier way to check for an existance of a file is to simply FileOpen it as so:
  140. handle = FileOpen('match.cmd', 'rs')
  141. IF handle <> 0 THEN DO
  142.     SAY "File exists"
  143.     CALL FileClose(handle)
  144. END
  145. ELSE SAY "File doesn't exist"
  146. */
  147.  
  148.  
  149.  
  150. /* =============================================================================== */
  151. /* FileDropFuncs: This unloads all of the functions in the FILEREXX DLL. This is not necessary, and
  152.     we could otherwise leave it open for some other REXX script */
  153. CALL FileDropFuncs
  154.