home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / spooler.lha / File1 < prev    next >
Encoding:
Text File  |  1988-09-24  |  2.7 KB  |  95 lines

  1. /*---------------------------- Start REXX Source ----------------------------*/
  2.  
  3. /*   **************************/
  4. /*   * Print selector program */
  5. /*   *   using ARexx v1.06    */
  6. /*   *         by             */
  7. /*   *      Dan Schenck      */
  8. /*   *       22-SEP-88      */
  9. /*   *         v 1.00      */
  10. /*   **********************/
  11.  
  12. signal on BREAK_C
  13. true = 1
  14. false = 0
  15. address command
  16. cdir = pragma('D')
  17.  
  18. arg name .
  19. call parse_dir
  20. do forever
  21.   do while(name = "df0:||||")
  22.     name = getfile(200,200,cdir,,'Select File to Print or CANCEL to EXIT')
  23.     if name = "" then call end_all()
  24.     call parse_dir
  25.   end
  26.   address command
  27.   if index(cdir,":") = 0 then file2show = pragma('D') || cdir || "/" || name
  28.   else if right(cdir,1) ~= ":" then file2show = cdir || "/" || name
  29.        else file2show = cdir || name
  30.   if ~showlist("P","SPOOLER") then
  31.     do
  32.       'rx' "rexx:spooler_utility INSTALL"
  33.       do while(~showlist("P","SPOOLER"))
  34.         call delay(150)
  35.       end
  36.     end
  37.   address "SPOOLER" "PRINT " || file2show
  38.   name = "df0:||||"        
  39. end
  40.  
  41. /*                            parse_dir Procedure                           */
  42. /*                                                                          */
  43. /*  Separate the directory portion of the file name if there is any from    */
  44. /*  the file name itself.  "cdir" will contain the new directory or be left */
  45. /*  untouched if there is no directory.  "name" will be modified to only    */
  46. /*  contain the file name itself or "df0:||||" if there is no file name.    */
  47.  
  48. parse_dir: procedure expose cdir name
  49.   if length(name) = 0 then
  50.     do /*  No name or directory  */
  51.       name = "df0:||||"
  52.       return
  53.     end
  54.   if ~exists(name) then
  55.     do /*  Bad directory/file name  */
  56.       name = "df0:||||"
  57.       return
  58.     end
  59.   i_colon = lastpos(":",name)
  60.   i_slash = lastpos("/",name)
  61.   if left(statef(name),1) = "F" then
  62.     do /*  This a file, not just a directory  */
  63.       if i_slash > 0 then
  64.         do /*  At least one subdirectory has been given  */   
  65.           cdir = substr(name,1,i_slash-1)
  66.           name = substr(name,i_slash+1)
  67.           return
  68.         end
  69.       if i_colon > 0 then
  70.         do /*  A main directory has been given  */
  71.           cdir = substr(name,1,i_colon)
  72.           name = substr(name,i_colon+1)
  73.           return
  74.         end
  75.       return
  76.     end
  77.   if i_slash > 0 then
  78.     do /*  A subdirectory with no file has been given  */
  79.       cdir = name
  80.       name = "df0:||||"
  81.       return
  82.     end
  83.   /*  A main directory or subdirectory only has been given  */
  84.   if i_colon = 0 then cdir = cdir || name
  85.   else cdir = name
  86.   name = "df0:||||"
  87.   return
  88.  
  89. BREAK_C:
  90.   call end_all()
  91. end_all: procedure
  92.   exit
  93.  
  94. /*----------------------------- End REXX Source -----------------------------*/
  95.