home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / loccmds2.zip / locp.cmd < prev    next >
OS/2 REXX Batch file  |  1997-05-07  |  2KB  |  52 lines

  1. /* LocP - REXX program to search all paths of the 'PATH' statement for possible
  2.           resolutions to the specified argument (program).
  3.  
  4.    RRC 02/11/97 initial version - Note: should look for '.cmd' & '.exe'
  5. */
  6.  
  7. call RxFuncAdd SysLoadFuncs, RexxUtil, SysLoadFuncs
  8. call SysLoadFuncs
  9.  
  10. '@echo off'
  11.  
  12. PARSE ARG What .
  13.  
  14. if What = "" then
  15. do
  16.     say 'No arguments given.'
  17.     say ''
  18.     say 'locp FileName'
  19.     say ''
  20.     say 'Locate where in your "path" string a file exists.  Requires one parameter.'
  21.     say 'The first parameter must be a filename to search for.'
  22.     say ''
  23.     exit
  24. end
  25.  
  26. WorkPath=value('PATH',,'OS2ENVIRONMENT')  /* Pick up current %PATH%           */
  27.  
  28. do FOREVER                              /* Until 'exit'                       */
  29.  
  30.   PARSE VAR WorkPath SearchPath';'WorkPath  /* Pull consecutive 'path's       */
  31.  
  32.   if SearchPath = '' THEN DO            /* If we've run out                   */
  33.  
  34.     exit 0                              /* And done                           */
  35.   END
  36.  
  37.   SearchPath = STRIP(SearchPath)        /* Remove blanks (should not be!)     */
  38.   if RIGHT( SearchPath, 1 ) = '\'       /* If this path ends in bs            */
  39.   THEN SearchPath = LEFT(SearchPath, LENGTH(SearchPath)-1)  /* Strip it       */
  40.  
  41.   rc = SysFileTree( SearchPath||'\'||What||'*', 'MatchList', 'F' )
  42.   if rc <> 0 then do
  43.     say 'Serious error: insufficient memory to run SysFileTree.  Error 'rc
  44.     exit 3
  45.   END
  46.  
  47.   DO ii=1 to MatchList.0
  48.     say MatchList.ii
  49.   END
  50.  
  51. END
  52.