home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 357.lha / FMutils / RExxRun.rexx < prev   
OS/2 REXX Batch file  |  1990-03-13  |  4KB  |  109 lines

  1. /*---------------------------- Start REXX Source ----------------------------*/
  2.  
  3. /*   *      Adapted from Dan Schenck's print spooler.  Thanks, Dan!     */
  4.  
  5. /* Modified by Steven D. Kapplin on 27-NOV-89                           */
  6. /*    RUN any program or script (if script (s) bit set) with arguments   */
  7. /*    by inserting a space after filename and entering any arguments     */
  8. /*    before clicking on OK.  Start program with '?' for help; if a      */
  9. /*    path follows, then RExxRun logs into that path or defaults to VD0: */
  10. /*   Command syntax:  RExxRun [? | path | device].  If no arg is        */
  11. /*   supplied then RExxRun logs into VD0:.  Change this if you prefer   */
  12. /*   to default to a different device or path.                          */
  13. /*   Can be used as a utility with FastMenu1.rexx.                      */
  14.  
  15. if ~show(L,'rexxsupport.library') then
  16.   rc = addlib('rexxsupport.library',0,-30,0)
  17.  
  18. if ~show(L,'rexxarplib.library') then
  19.   rc = addlib('rexxarplib.library',0,-30,0)
  20.  
  21. signal on BREAK_C
  22. true = 1
  23. false = 0
  24. name = "df0:||||"        
  25. parse arg cdir .
  26. if cdir = "?" then call banner
  27.  
  28. /* Change VD0: to the path or device of your choice */
  29.  
  30. if cdir = "" then cdir = "VD0:"
  31. do forever
  32.   do while(name = "df0:||||")
  33.     arg_flag = false
  34.     name = getfile(340,11,cdir,,'RExxRun - Select Program')
  35.     if name = "" then call end_all()
  36.     nw = words(name)
  37.     parms = subword(name,2,nw-1)
  38.     name = word(name,1)
  39.     call parse_dir
  40.   end
  41.   address command
  42.   if index(cdir,":") = 0 then file2show = pragma('D') || cdir || "/" || name
  43.   else if right(cdir,1) ~= ":" then file2show = cdir || "/" || name
  44.        else file2show = cdir || name
  45.   ADDRESS COMMAND 'run' file2show || " " || parms
  46.   name = "df0:||||"        
  47. end
  48.  
  49. /*                            parse_dir Procedure                           */
  50. /*                                                                          */
  51. /*  Separate the directory portion of the file name if there is any from    */
  52. /*  the file name itself.  "cdir" will contain the new directory or be left */
  53. /*  untouched if there is no directory.  "name" will be modified to only    */
  54. /*  contain the file name itself or "df0:||||" if there is no file name.    */
  55.  
  56. parse_dir: procedure expose cdir name
  57.   if length(name) = 0 then
  58.     do /*  No name or directory  */
  59.       name = "df0:||||"
  60.       return
  61.     end
  62.   if ~exists(name) then
  63.     do /*  Bad directory/file name  */
  64.       name = "df0:||||"
  65.       return
  66.     end
  67.   i_colon = lastpos(":",name)
  68.   i_slash = lastpos("/",name)
  69.   if left(statef(name),1) = "F" then
  70.     do /*  This a file, not just a directory  */
  71.       if i_slash > 0 then
  72.         do /*  At least one subdirectory has been given  */   
  73.           cdir = substr(name,1,i_slash-1)
  74.           name = substr(name,i_slash+1)
  75.           return
  76.         end
  77.       if i_colon > 0 then
  78.         do /*  A main directory has been given  */
  79.           cdir = substr(name,1,i_colon)
  80.           name = substr(name,i_colon+1)
  81.           return
  82.         end
  83.       return
  84.     end
  85.   if i_slash > 0 then
  86.     do /*  A subdirectory with no file has been given  */
  87.       cdir = name
  88.       name = "df0:||||"
  89.       return
  90.     end
  91.   /*  A main directory or subdirectory only has been given  */
  92.   if i_colon = 0 then cdir = cdir || name
  93.   else cdir = name
  94.   name = "df0:||||"
  95.   return
  96.  
  97. BREAK_C:
  98.   call end_all()
  99. end_all: procedure
  100.   exit
  101.  
  102. banner:
  103.     Say "Command Syntax: RExxRun [?] | [<path>]"
  104.      Say "    ? displays this message"
  105.     Say "    <path> sets login path - default path ==> VD0:"
  106.     exit 5
  107.  
  108. /*----------------------------- End REXX Source -----------------------------*/
  109.