home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / forums.cmd < prev    next >
OS/2 REXX Batch file  |  1995-05-19  |  2KB  |  63 lines

  1. /* Name:         FORUMS.CMD                                              */
  2. /* Purpose:      Remove all records from FORUMS.LST file that do not     */
  3. /*               have the word "FORUM" in them.                          */
  4. /* Author:       Joseph R. Franchina 74674.2144@compuserve.com           */
  5.  
  6. /* Description:  This procudure will take the GCP FORUMS.LST file and    */
  7. /*               remove all entries that do not contain the word "FORUM" */
  8. /*               The result file is called CLEAN.LST.  Copy this file    */
  9. /*               to FORUMS.LST. This procedure does not do this so as to */
  10. /*               allow you to backup the complete list for future        */
  11. /*               reference.  This might also be insurance against any    */
  12. /*               error I might have made, I'm no REXX genius :)          */
  13.  
  14. /* DISCLAIMER:   I have tested this procedure and have found no problems.*/
  15. /*               With that said proceed at your own risk.                */
  16.  
  17. /* NOTE:         Change the following to reflect your drive and directory*/
  18. /*               for GCP.                                                */
  19. filein  = 'c:\gcp\forums.lst' 
  20. fileout = 'c:\gcp\clean.lst' 
  21.  
  22. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  23. call SysLoadFuncs
  24.  
  25. kept = 0
  26. discarded = 0
  27.  
  28. call SysFileDelete fileout
  29.  
  30. if stream(filein,'c','open read') <> 'READY:' then
  31.   do
  32.     say "Cannot open" filein "for read."
  33.     exit
  34.   end /* do */
  35.   
  36. if stream(fileout,'c','open write') <> 'READY:' then
  37.   do
  38.     say "Cannot open" fileout "for write."
  39.     exit
  40.   end /* do */
  41.  
  42. do until stream(filein) <> 'READY'
  43.   source_line = linein(filein)
  44.   parse upper var source_line upper_source_line
  45.   
  46.   if wordpos('FORUM',upper_source_line) > 0
  47.   then 
  48.     do
  49.       call lineout fileout, source_line
  50.       kept = kept + 1
  51.     end /* do */
  52.   else discarded = discarded + 1
  53.  
  54. end /* do */
  55.  
  56. say kept 'lines written'
  57. say discarded 'lines discarded'
  58.  
  59. call stream filein 'c', 'close'
  60. call stream fileout 'c', 'close'
  61.  
  62. exit
  63.