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

  1. /*---------------------------- Start REXX Source ----------------------------*/
  2. /* RExxPrint.rexx                                             */
  3. /* Acts as front end for any Print program                      */
  4. /* Will pop up the Arp File Requestor if no file is supplied on */
  5. /* the command line or will pass the supplied file on to Print  */
  6. /* Can be run from FastMenu1.rexx as a print utility.  Substi-  */
  7. /* tute your own favorite print program.                        */
  8. /* Can be used as a standalone program.  The command line syntax*/
  9. /* is:  RExxPrint [? | filename].  If no arg is supplied on the */
  10. /* command line, then the Arp FileRequestor will pop up.  A ?   */
  11. /* will bring up a short message showing command syntax.        */
  12.  
  13. if ~show(L,'rexxsupport.library') then
  14.   rc = addlib('rexxsupport.library',0,-30,0)
  15.  
  16. if ~show(L,'rexxarplib.library') then
  17.   rc = addlib('rexxarplib.library',0,-30,0)
  18.  
  19. signal on BREAK_C
  20. cdir = pragma('D')
  21. parse arg filename .
  22. if filename = "?" then call banner
  23. if filename > "" then do
  24.  
  25. /* Substitute your program between the single quotes */
  26.  
  27.     ADDRESS COMMAND 'sys:PrintUtils/Print' filename
  28.     exit 
  29. end
  30. name = "df0:||||"
  31. do forever
  32. do while(name = "df0:||||")
  33.     name = getfile(340,11,cdir,,'Select File')
  34.     if name = "" then call end_all()
  35.     call parse_dir
  36.   end
  37.   address command
  38.   if index(cdir,":") = 0 then filename = pragma('D') || cdir || "/" || name
  39.   else if right(cdir,1) ~= ":" then filename = cdir || "/" || name
  40.        else filename = cdir || name
  41.   ADDRESS COMMAND 'sys:PrintUtils/Print' filename
  42.   name = "df0:||||"        
  43. end
  44.  
  45. /*                            parse_dir Procedure                           */
  46. /*                                                                          */
  47. /*  Separate the directory portion of the file name if there is any from    */
  48. /*  the file name itself.  "cdir" will contain the new directory or be left */
  49. /*  untouched if there is no directory.  "name" will be modified to only    */
  50. /*  contain the file name itself or "df0:||||" if there is no file name.    */
  51.  
  52. parse_dir: procedure expose cdir name
  53.   if length(name) = 0 then
  54.     do /*  No name or directory  */
  55.       name = "df0:||||"
  56.       return
  57.     end
  58.   if ~exists(name) then
  59.     do /*  Bad directory/file name  */
  60.       name = "df0:||||"
  61.       return
  62.     end
  63.   i_colon = lastpos(":",name)
  64.   i_slash = lastpos("/",name)
  65.   if left(statef(name),1) = "F" then
  66.     do /*  This a file, not just a directory  */
  67.       if i_slash > 0 then
  68.         do /*  At least one subdirectory has been given  */   
  69.           cdir = substr(name,1,i_slash-1)
  70.           name = substr(name,i_slash+1)
  71.           return
  72.         end
  73.       if i_colon > 0 then
  74.         do /*  A main directory has been given  */
  75.           cdir = substr(name,1,i_colon)
  76.           name = substr(name,i_colon+1)
  77.           return
  78.         end
  79.       return
  80.     end
  81.   if i_slash > 0 then
  82.     do /*  A subdirectory with no file has been given  */
  83.       cdir = name
  84.       name = "df0:||||"
  85.       return
  86.     end
  87.   /*  A main directory or subdirectory only has been given  */
  88.   if i_colon = 0 then cdir = cdir || name
  89.   else cdir = name
  90.   name = "df0:||||"
  91.   return
  92.  
  93. BREAK_C:
  94.   call end_all()
  95. end_all: procedure
  96.   exit
  97.  
  98. banner:
  99.     Say "Command Syntax: RExxPrint <?> | <filename>"
  100.      Say "    ? displays this message"
  101.     Say "    filename - Prints <filename>"
  102.     Say "    no argument brings up Arp File Requestor"
  103.     exit 5
  104.  
  105. /*----------------------------- End REXX Source -----------------------------*/
  106.