home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / REXXOV.ZIP / seek.ovr < prev   
Text File  |  1992-08-14  |  2KB  |  52 lines

  1. /* seek and scan files */
  2.                                        /* register the rexxutil pkg  */
  3. if rxfuncadd('SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs') = 0 then
  4.   call sysloadfuncs
  5. parse arg filespec, text               /* get the file name and text */
  6. if filespec = '' then do               /* no name?                   */
  7.                                        /* display an error message   */
  8.   call rxmessagebox "A file name must be specified","Seek and Scan", "OK", "Error"
  9.   exit
  10. end
  11.                                        /* search for the file        */
  12. call sysfiletree filespec, 'list.', 'FOS'
  13. if list.0 = 0 then do                  /* nothing found?             */
  14.                                        /* give an error              */
  15.   call rxmessagebox "No files were found matching '"filespec"'","Seek and Scan" , "OK", "Information"
  16.   exit
  17. end
  18.  
  19.                                        /* delete existing file list  */
  20. if stream('filelist.dat','C', 'QUERY EXISTS') <> '' then do
  21.   if sysfiledelete("filelist.dat") <> 0 then do
  22.     '@CLOSE("FileList")'
  23.     call sysfiledelete "filelist.dat"
  24.   end
  25. end
  26.  
  27. if text = '' then do                   /* not a text search?         */
  28.   do i=1 to list.0                     /* return the entire list     */
  29.     call lineout "filelist.dat", list.i
  30.   end
  31. end
  32. else do                                /* need to search each file   */
  33.   match = 0                            /* no matches yet             */
  34.   do i=1 to list.0
  35.                                        /* search for the text        */
  36.     call sysfilesearch text, list.i, 'lines.', 'N'
  37.     if lines.0 <> 0 then do            /* found something?           */
  38.                                        /* add to the list            */
  39.       call lineout "filelist.dat", list.i
  40.       match = match + 1                /* step the match count       */
  41.     end
  42.   end
  43.   if match = 0 then do                 /* nothing found?             */
  44.                                        /* give an error              */
  45.     call rxmessagebox "No files were found containing '"text"'","Seek and Scan" , "OK", "Information"
  46.     exit
  47.   end
  48. end
  49.                                        /* close the file             */
  50. call stream "filelist.dat", "c", "close"
  51. '@ASCIIOPEN("FileList", "filelist.dat", "Located files", 0)'
  52.