home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / REXPRT21.ZIP / REXXPRNT.CMD
OS/2 REXX Batch file  |  1991-10-04  |  8KB  |  210 lines

  1. /* REXX print program for HP Laserjet printers 10-10-90 -msj */
  2. /*                                                               */
  3. /*                                                               */
  4. /*      MODIFIED ON 10/03/91 TO CHECK FOR A '012' CODE IN A      */
  5. /*      FILE AND PROPERLY HANDLE IT.     BOB WALTERS             */
  6. /*                                                               */
  7. /*                                                               */
  8.  
  9. /*  TRACE ?I   */
  10.  
  11. arg files
  12.  
  13. filedrv = filespec('drive',files)
  14. filepth = filespec('path',files)
  15.  
  16. SAY ' '
  17. SAY 'REXX PRINT PROGRAM FOR HP LASERJET PRINTERS'
  18. SAY ' '
  19. SAY '     PRINTS 125 COLUMNS AND 74 LINES ON A  '
  20. SAY '     8 1/2 BY 11 INCH FORM.                '
  21. SAY ' '
  22.  
  23. if length(space(files, 0)) = 0 then
  24.     do
  25.     say ' '
  26.     say 'Specify a file name to print!'
  27.     exit
  28.     end
  29.  
  30. tempfile='prtlist$.$$$'
  31.  
  32. '@dir' files '/n >NUL'
  33.  
  34. if RC>0 then
  35.     do
  36.     say ' '
  37.     say 'Error getting file names!'
  38.     say 'Cancelling print request!'
  39.     exit
  40.     end
  41.  
  42. '@dir' files '/n | sort >' tempfile
  43.  
  44. call charout prn, D2C(27)||D2C(69)                             /* reset printer                      */
  45. call charout prn, D2C(27)||D2C(40)||D2C(115)||D2C(48)||D2C(84) /* set to LINEPRINTER font            */
  46. call charout prn, D2C(27)||D2C(40)||D2C(49)||D2C(48)||D2C(85)  /* set to 10U                         */
  47. call charout prn, D2C(27)||D2C(40)||D2C(115)||'16.6'||D2C(72)  /* set to compressed 17 char per inch */
  48. call charout prn, D2C(27)||D2C(40)||D2C(115)||'8.5'||D2C(86)   /* set to 8.5 point text              */
  49. call charout prn, D2C(27)||D2C(40)||D2C(115)||'48'||D2C(80)    /* set to fixed spacing               */
  50. call charout prn, D2C(27)||D2C(38)||D2C(108)||D2C(49)||D2C(69) /* set to NO TOP MARGIN               */
  51. call charout prn, D2C(27)||D2C(38)||D2C(108)||D2C(56)||D2C(68) /* set to 8 lpi                       */
  52. call lineout , ''
  53.  
  54. printed=0
  55.  
  56. do x=1
  57.     if lines(tempfile)=0 then leave
  58.     direntry=linein(tempfile)
  59.     isdir=pos(" <DIR> ", direntry)
  60.     if isdir=0 then do
  61.         isfile=substr(direntry,3,1)
  62.         if isfile='-' then
  63.             do
  64.  
  65.             fileid=filedrv||filepth||substr(direntry,41)
  66.             call charout , D2C(27)||'[s'
  67.  
  68.             /* print file */
  69.  
  70.             pageno = 0
  71.             lineno = 74
  72.             borderline = copies('─',130)
  73.             do while lines(fileid) > 0
  74.                 if lineno = 74 then
  75.                     do
  76.                     if pageno \= 0 then
  77.                         do
  78.                         call lineout prn, ' '
  79.                         bottomline = overlay(' continued ──────',borderline,112)
  80.                         call lineout prn, bottomline
  81.                         pageline = center('- Page' pageno '-',130)
  82.                         call lineout prn, pageline
  83.                         call charout prn, D2C(12)
  84.                         end
  85.                      dateline = strip(right(time('C')  date('W')',' date('M') substr(date('S'),7,2)',' substr(date('S'),1,4),130),'t')
  86.                      headerline = overlay(dateline,pageline)
  87.                      headerline = overlay(fileid,headerline)
  88.                      call lineout prn, ''
  89.                      call lineout prn, headerline
  90.                      call lineout prn, borderline
  91.                      call lineout prn, ''
  92.                      lineno = 1
  93.                      pageno = pageno + 1
  94.                      call charout , D2C(27)||'[u'
  95.                      call charout , 'Printing Page '||pageno||' of '||fileid
  96.                      end
  97.                 call FINDIT
  98.                 call lineout prn, '      '||LINEWORK
  99.                 lineno = lineno + 1
  100.                 end
  101.             call lineout prn, ''
  102.             bottomline = overlay(' end-of-file ──────',borderline,110)
  103.             call lineout prn, bottomline
  104.             pageline = center('- Page' pageno '-',130)
  105.             call lineout prn, pageline
  106.             call lineout fileid
  107.             call lineout , ''
  108.             printed = printed + 1
  109.             call charout prn, D2C(12)
  110.             end
  111.             /* done printing current file */
  112.         end
  113.     end
  114.  
  115. /* reset and close printer */
  116.  
  117. call charout prn, D2C(27)||D2C(69)
  118. call lineout prn
  119.  
  120. call lineout , ''
  121. pageline = printed||' file(s) printed.'
  122. call charout , pageline
  123. call lineout , ''
  124.  
  125. /* cleanup temporary file */
  126.  
  127. call stream tempfile, "C", "close"
  128.  
  129. "@del" tempfile
  130. exit
  131.  
  132.  
  133. FINDIT:
  134.     LINEWORK = LINEIN(FILEID)
  135.      PRTPOS = 0
  136.      FOUND012 = 0
  137.      IF LENGTH(LINEWORK) = 0
  138.          THEN RETURN
  139.      PRTPOS = POS(D2C(012),LINEWORK)
  140.      IF PRTPOS > 0
  141.              THEN DO
  142.                LINENO = 73
  143.                FOUND012 = 1
  144.                  IF PRTPOS = 1
  145.                    THEN DO
  146.                         LINEWORK = SUBSTR(LINEWORK,PRTPOS+1)||' '
  147.                         call lineout prn, ' '
  148.                         bottomline = overlay(' continued ──────',borderline,112)
  149.                         call lineout prn, bottomline
  150.                         pageline = center('- Page' pageno '-',130)
  151.                         call lineout prn, pageline
  152.                         call charout prn, D2C(12)
  153.                         dateline = strip(right(time('C')  date('W')',' date('M') substr(date('S'),7,2)',' substr(date('S'),1,4),130),'t')
  154.                         headerline = overlay(dateline,pageline)
  155.                         headerline = overlay(fileid,headerline)
  156.                         call lineout prn, ''
  157.                         call lineout prn, headerline
  158.                         call lineout prn, borderline
  159.                         call lineout prn, ''
  160.                         lineno = 1
  161.                         pageno = pageno + 1
  162.                         call charout , D2C(27)||'[u'
  163.                         call charout , 'Printing Page '||pageno||' of '||fileid
  164.                    END
  165.                  IF PRTPOS > 1
  166.                    THEN DO
  167.                         LINEWRK2 = LINEWORK
  168.                         LINEWORK = SUBSTR(LINEWORK,1,PRTPOS-1)||' '
  169.                      IF PRTPOS < LENGTH(LINEWRK2)
  170.                         THEN DO
  171.                         call lineout prn, '      '||LINEWORK
  172.                         call lineout prn, ' '
  173.                         bottomline = overlay(' continued ──────',borderline,112)
  174.                         call lineout prn, bottomline
  175.                         pageline = center('- Page' pageno '-',130)
  176.                         call lineout prn, pageline
  177.                         call charout prn, D2C(12)
  178.                         dateline = strip(right(time('C')  date('W')',' date('M') substr(date('S'),7,2)',' substr(date('S'),1,4),130),'t')
  179.                         headerline = overlay(dateline,pageline)
  180.                         headerline = overlay(fileid,headerline)
  181.                         call lineout prn, ''
  182.                         call lineout prn, headerline
  183.                         call lineout prn, borderline
  184.                         call lineout prn, ''
  185.                         lineno = 1
  186.                         pageno = pageno + 1
  187.                         call charout , D2C(27)||'[u'
  188.                         call charout , 'Printing Page '||pageno||' of '||fileid
  189.                         LINEWORK = SUBSTR(LINEWRK2,PRTPOS+1)||' '
  190.                         END
  191.                    END
  192.              END
  193. RETURN
  194.  
  195.  
  196.  
  197. /*         FIDONET:  Matt Johnson @1:376/32.0                    */
  198. /*       or USENET:  uunet!usceast!uscacm!32!Matt.Johnson        */
  199. /*                                                               */
  200. /*                                                               */
  201. /*                                                               */
  202. /*                                                               */
  203. /*       MODIFIED FOR PROPER CHECKING OF A '012' CODE WITHIN     */
  204. /*       A FILE AND WHEN DETECTED HANDLE IT WITH THE PROPER      */
  205. /*       END-OF-PAGE ROUTINE.  THIS CHANGE HAS BEEN TESTED ON    */
  206. /*       OS/2 1.3 EXTENDED EDITION-CSD LEVEL WR05016 AND AN      */
  207. /*       OKIDATA OL400 LASER PRINTER - USING HP-II EMULATION.    */
  208. /*                                       BOB WALTERS 10/03/91    */
  209. /*                                                               */
  210.