home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / clrlib.cmd < prev    next >
OS/2 REXX Batch file  |  1994-09-12  |  3KB  |  78 lines

  1. /* This REXX utility, used in conjunction with Golden Commpass, */
  2. /* automatically erases any catalog files when a download file  */
  3. /* containing a "DIR" command is detected. (e.g. when you are   */
  4. /* going to refresh the catalog from CompuServe)  This, in      */
  5. /* effect, "cleans out" your catalog so only new entries are    */
  6. /* shown after the download.                                    */
  7.  
  8. /* This function can be called from GCP                         */
  9. /* GCP automatically before each online session by adding it    */
  10. /* to page three of the "Online" section in the settings        */
  11. /* notebook, under "pre-processing exit", as OS/2, BG.  You     */
  12. /* must specify the full path name for your Messages path.      */
  13. /* (It doesn't matter if you include the trailing slash or not) */
  14.  
  15. /* Example:  clrlib D:\COMM                                     */
  16.  
  17. /* Comments are welcome!  Peter A. Kazmir 71501,336             */
  18.  
  19. /* Load relevant functions */
  20. call rxfuncadd 'SysFileTree', 'RexxUtil','SysFileTree'
  21. call rxfuncadd 'SysFileSearch', 'RexxUtil','SysFileSearch'
  22. call rxfuncadd 'SysFileDelete', 'RexxUtil','SysFileDelete'
  23.  
  24. /* Clear flag */
  25. del=0
  26.  
  27. /* Get pathname of Messages directory */
  28. parse arg directory
  29.  
  30. /* Make sure the path does not have a trailing slash */
  31. directory=strip(directory , 'T' , '\' )
  32.  
  33. /* Check for valid pathname */
  34. call SysFileTree directory , 'dirx' , 'DO'
  35. if (length(directory)=0 | dirx.0=0) then do
  36.   say ''
  37.   say 'ERROR: Invalid or missing pathname'
  38.   say ''
  39.   say 'The syntax for this command is:'
  40.   say ''
  41.   say '  clrlib <dir> '
  42.   say ''
  43.   say 'where <dir> is your GCP Messages Path (ex: D:\COMM).'
  44.   exit
  45. end
  46.  
  47. /* Check for DOWnload files in the directory; give list to files array */
  48. call SysFileTree directory'\*.DOW' , 'files' , 'FO'
  49.  
  50. /* For each file found, search for word "DIR" in the file.  If found,  */
  51. /* delete cooresponding CATalog file in the directory.                 */
  52. do i = 1 to files.0
  53.   call SysFileSearch 'DIR' , files.i , 'line' , 'N'
  54.  
  55.   if line.0 > 0 then do
  56.  
  57.     /* Set flag */
  58.     del=1
  59.  
  60.     /* Create filename to delete (d:\path\forum.CAT) */
  61.     file_kill=substr(files.i,1,length(files.i)-4)'.CAT'
  62.  
  63.     /* Delete file and pass return code */
  64.     rc=SysFileDelete(file_kill)
  65.  
  66.     if rc=0 then say file_kill' deleted.'
  67.     else if rc=2 then say file_kill' does not exist.'
  68.     else say rc': Error deleting' file_kill
  69.  
  70.   end
  71.  
  72. end
  73.  
  74. /* If no CATalog files were printed, print message */
  75. if del=0 then say 'No files were found to delete.'
  76.  
  77. exit
  78.