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

  1. /*****************************************************************************/
  2. /*                                                                           */
  3. /* Print an ASCII file on a Postscript printer                               */
  4. /*                                                                           */
  5. /* Requires Personal REXX or REXXLIB (dosisdir & dosisfile functions)        */
  6. /*                                                                           */
  7. /* Command format: ASC2PS <infile> <outfile>                                 */
  8. /*                                                                           */
  9. /*****************************************************************************/
  10.  
  11. arg infile outfile .
  12. if dosdir(infile) = '' then do
  13.     say "Input file '"infile"' not found."
  14.     exit
  15.     end
  16. if outfile = '' then
  17.     outfile = 'PRN'
  18.  
  19. if dosisfile(outfile) then
  20.     call dosdel outfile
  21. call pageinit
  22.  
  23. i = 0
  24. deltay = 72 * 11 / 66
  25. do while lines(infile)
  26.     line = linein(infile)
  27.     i = i + 1
  28.     call lineout outfile, 0 (66-i) * deltay 'moveto'
  29.     line = quote(line, "\()")
  30.     call lineout outfile, '('line') show'
  31.     if i < 66 then
  32.         iterate
  33.     call lineout outfile, 'showpage restore'
  34.     call pageinit
  35.     i = 0
  36.     end
  37. if i > 0 then
  38.     call lineout outfile, 'showpage'
  39. call lineout outfile, 'restore'
  40. call lineout outfile
  41. call lineout infile
  42. exit
  43.  
  44. /* initialize page */
  45. pageinit:
  46. call lineout outfile, 'save 36 36 translate'
  47. call lineout outfile, '.9375 .9091 scale'
  48. call lineout outfile, '/Courier findfont 12 scalefont setfont'
  49. return
  50.  
  51. /* insert escape characters */
  52. quote: procedure
  53. parse arg line, quotechars
  54. x = 1
  55. do forever
  56.     x = verify(line, quotechars, 'm', x)
  57.     if x = 0 then
  58.         leave
  59.     line = insert('\', line, x-1)
  60.     x = x + 2
  61.     end
  62. return line
  63.