home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxlb.zip / SAMPLES / PS4UP.CMD < prev    next >
OS/2 REXX Batch file  |  1993-02-28  |  2KB  |  90 lines

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /* Print an ASCII file on a Postscript printer, 4 pages per sheet            */
  4. /*                                                                           */
  5. /* Requires Personal REXX or REXXLIB (dosdir, dosdel, & dosisfile functions) */
  6. /*                                                                           */
  7. /* Command format: PS4UP <infile> <outfile>                                  */
  8. /*                                                                           */
  9. /*****************************************************************************/
  10.  
  11. signal on novalue
  12. arg infile outfile .
  13. if dosdir(infile) = '' then do
  14.     say "Input file '"infile"' not found."
  15.     exit
  16.     end
  17. if outfile = '' then
  18.     outfile = 'PRN'
  19.  
  20. if dosisfile(outfile) then
  21.     call dosdel outfile
  22. call pageinit
  23.  
  24. lines_per_page = 66
  25. deltay = 72 * 5.5 / lines_per_page
  26. xstart.1 = 0
  27. ystart.1 = 72 * 5.75
  28. xstart.2 = 72 * 8.5 / 2
  29. ystart.2 = ystart.1
  30. xstart.3 = 0
  31. ystart.3 = 0
  32. xstart.4 = xstart.2
  33. ystart.4 = ystart.3
  34. lineno = 0
  35. quadrant = 1
  36. showpage = 0
  37.  
  38. do while lines(infile)
  39.     line = linein(infile)
  40.     line = quote(line, "\()")
  41.     call print_line line
  42.     end
  43.  
  44. if showpage then
  45.     call lineout outfile, 'showpage'
  46. call lineout outfile, 'restore'
  47. call lineout outfile
  48. call lineout infile
  49. exit
  50.  
  51. /* print one line */
  52. print_line: procedure expose lineno showpage lines_per_page deltay xstart.,
  53.     ystart. quadrant outfile
  54. parse arg line
  55. lineno = lineno + 1
  56. showpage = 1
  57. ypos = trunc((lines_per_page-lineno) * deltay + ystart.quadrant)
  58. call lineout outfile, xstart.quadrant ypos 'moveto'
  59. call lineout outfile, '('line') show'
  60. if lineno < lines_per_page then
  61.     return
  62. lineno = 0
  63. if quadrant = 4 then do
  64.     call lineout outfile, 'showpage restore'
  65.     call pageinit
  66.     showpage = 0
  67.     end
  68. quadrant = quadrant // 4 + 1
  69. return
  70.  
  71. /* initialize page */
  72. pageinit:
  73. call lineout outfile, 'save 36 36 translate'
  74. call lineout outfile, '.9375 .9091 scale'
  75. call lineout outfile, '/Courier findfont 6 scalefont setfont'
  76. return
  77.  
  78. /* insert escape characters */
  79. quote: procedure
  80. parse arg line, quotechars
  81. x = 1
  82. do forever
  83.     x = verify(line, quotechars, 'm', x)
  84.     if x = 0 then
  85.         leave
  86.     line = insert('\', line, x-1)
  87.     x = x + 2
  88.     end
  89. return line
  90.