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

  1. /*---------------------------- Start REXX Source ----------------------------*/
  2.  
  3. /*   *************************/
  4. /*   *    Printit program    */
  5. /*   *   using ARexx v1.06   */
  6. /*   *         by            */
  7. /*   *      Dan Schenck      */
  8. /*   *       22-SEP-88      */
  9. /*   *         v 1.00      */
  10. /*   **********************/
  11. spool_names = 'vd0:$$spooler'
  12.  
  13. parse arg file2print orig_file cc
  14.  
  15. cc = translate(cc,' ','15'X)
  16. schar = '/f'
  17. rchar = '0C'X
  18. call look4spec_char
  19. schar = '/n'
  20. rchar = '0A'X
  21. call look4spec_char
  22.  
  23. if file2print = "" then
  24.   do
  25.     call check4more()
  26.     address "SPOOLER" "DONE"
  27.     exit
  28.   end
  29. call printit()
  30. call check4more()
  31. address "SPOOLER" "DONE"
  32. exit
  33.  
  34. check4more: procedure expose spool_names cc
  35.   offset = 0
  36.   endofin = 0
  37.   do forever
  38.     if (~exists(spool_names)) then return
  39.     instring = statef(spool_names)
  40.     parse VAR instring file ' ' bytes ' ' rest
  41.     do while(~open('in',spool_names,'Read'))
  42.       call delay(500)
  43.     end
  44.     if offset > 0 then
  45.       do
  46.         if offset < bytes then call seek('in',offset,'B')
  47.         else endofin = 1
  48.       end
  49.     if (~endofin) then
  50.       do
  51.         instring = readln('in')
  52.         parse VAR instring file2print ' ' orig_file ' ' rest
  53.         call close('in')
  54.         call printit
  55.         offset = offset + length(file2print) + length(orig_file) + 2
  56.       end
  57.     else
  58.       do
  59.         call close('in')
  60.         call delay(100)
  61.         address command
  62.         'delete' spool_names "quiet"
  63.         return
  64.       end
  65.   end
  66.  
  67. printit: procedure expose file2print orig_file cc
  68.   address command
  69.   if ~exists(file2print) then
  70.     do
  71.       say '"' || file2print || '" Does Not Exist"'
  72.       return
  73.     end
  74.   do while(~open('out','PRT:','Write'))
  75.     call delay(300)
  76.   end
  77.   call writech('out',cc)
  78.   call writeln('out','Date: ' || date() || '     Time: ' || Time())
  79.   call writeln('out','File: ' || orig_file)
  80.   call writeln('out',' ')
  81.   prntfile = 'pfile'
  82.   call open(prntfile,file2print,'Read')
  83.   do while(~eof(prntfile))
  84.     instring = readln(prntfile)
  85.     call writeln('out',instring)
  86.   end
  87.   call close(prntfile)
  88.   call close('out')
  89.   if (index(upper(file2print),"$$RXSPOOL/$$") > 0) then
  90.     'delete' file2print || " Quiet"
  91.   return
  92.  
  93. look4spec_char: procedure expose cc schar rchar
  94.  
  95.   spec_char = index(cc,schar)
  96.   do while(spec_char > 0)
  97.     if (spec_char + 2) > length(cc) then cc_rest = ""
  98.     else cc_rest = substr(cc,spec_char+2)
  99.     if spec_char = 1 then cc = ""
  100.     else cc = substr(cc,1,spec_char-1)
  101.     cc = cc || rchar || cc_rest
  102.     spec_char = index(cc,schar)
  103.   end
  104.   return
  105.  
  106. /*----------------------------- End REXX Source -----------------------------*/
  107.