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

  1. /*---------------------------- Start REXX Source ----------------------------*/
  2.  
  3. /*   *************************/
  4. /*   * Print_spooler program */
  5. /*   *   using ARexx v1.06   */
  6. /*   *         by            */
  7. /*   *      Dan Schenck      */
  8. /*   *       22-SEP-88      */
  9. /*   *         v 1.00      */
  10. /*   **********************/
  11. true = 1
  12. false = 0
  13. ok = 0
  14. error = 20
  15. infile = "in"
  16. address command
  17. spool_names = 'vd0:$$spooler'
  18. copy_cntl = "rexx:spooler.copydir"
  19. prnt_done = true
  20. call open(infile,copy_cntl,'Read')
  21. copy_dir = readln(infile)
  22. cc = readln(infile)
  23. cc = translate(cc,'15'X,' ')
  24. call close(infile)
  25. count = 0
  26. time2exit = false
  27. say "ARexx Print Spooler"
  28. say "  by Dan Schenck"
  29. if copy_dir ~= "IN-PLACE/" then
  30.   do
  31.     copy_dir = copy_dir || "$$rxspool"
  32.     if exists(copy_dir) then 'delete' copy_dir || "/* Quiet"
  33.     else 'makedir' copy_dir
  34.     say "Print Files Will Be Copied To Spooler Directory """ || copy_dir || """"
  35.   end
  36. else say "Print Files To Be Copied ""In-Place"""
  37. call openport("SPOOLER")
  38. do forever
  39.   call waitpkt("SPOOLER")
  40.   packet = getpkt("SPOOLER")
  41.   instring = getarg(packet)
  42.   parse VAR instring command ' ' file2print
  43.   
  44.   select
  45.     when command = "EXIT" then
  46.       do
  47.         call reply(packet,ok)
  48.         if ~prnt_done then
  49.           do
  50.             say "Waiting on print to terminate before spooler exits"
  51.             time2exit = true
  52.           end            
  53.         else call End_All()
  54.       end
  55.     when command = "PRINT" then
  56.       do
  57.          bad_file = false
  58.          if left(statef(file2print),1) = "F" then call reply(packet,ok)
  59.          else 
  60.            do
  61.              call reply(packet,error)
  62.              bad_file = true
  63.            end
  64.          if bad_file then break
  65.          orig_file = file2print
  66.          if copy_dir ~= "IN-PLACE/" then
  67.            do
  68.              count = count + 1
  69.              copy_file = copy_dir || "/$$" || count
  70.              'copy' file2print " TO " copy_file
  71.              file2print = copy_file
  72.            end
  73.          if ~prnt_done then
  74.            do
  75.              if ~exists(spool_names) then mode = 'Write'
  76.              else mode = 'Append'
  77.              call open('out',spool_names,mode)
  78.              call writeln('out',file2print || ' ' || orig_file)
  79.              call close('out')
  80.              say '"' || orig_file || '" Queued To Print At ' || time()
  81.            end
  82.          else
  83.            do
  84.              address command
  85.              say '"' || orig_file || '" Queued To Print At ' || time()
  86.              'arun' "rx printit" file2print orig_file cc
  87.              prnt_done = false
  88.            end
  89.       end
  90.     when command = "DONE" then
  91.       do
  92.         call reply(packet,ok)
  93.         if time2exit then call End_All()
  94.         prnt_done = true
  95.       end
  96.     when command = "NFS" then
  97.       do
  98.         call reply(packet,ok)
  99.         cc = translate(file2print,' ','15'X)
  100.         say 'New file separator installed'
  101.       end        
  102.     otherwise call reply(packet,error)
  103.   end
  104. end
  105.  
  106. End_All: procedure expose copy_dir spool_names
  107.   address command
  108.   if copy_dir ~= "IN-PLACE/" then
  109.     do
  110.       'delete' copy_dir || "/* Quiet"
  111.       'delete' copy_dir || " Quiet"
  112.     end
  113.   if exists(spool_names) then 'delete' spool_names " Quiet"
  114.   call closeport("SPOOLER")
  115.   exit
  116.  
  117. /*----------------------------- End REXX Source -----------------------------*/
  118.