home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / print / ascii2ps / prntps / printps.cmd < prev   
Encoding:
Text File  |  1992-11-10  |  1.9 KB  |  56 lines

  1. /* PRINTPS.CMD - Print an ASCII file on a Postscript printer */
  2. /* Written by Michael Perks (10/31/92) */
  3. /* (c) Copyright IBM Corp. 1992 All Rights Reserved */
  4. output = 'LPT1'
  5. numlines = 80     /* right hand side may get clipped if font is too large */
  6. pagelength = 792  /* points or 11 inches */
  7. topmargin =  36   /* points or 0.5 inch  */
  8. bottommargin = 36 /* points or 0.5 inch  */
  9. leftmargin = 54   /* points or 0.75 inch */
  10. linesize = (pagelength - topmargin - bottommargin) / numlines
  11. parse arg filename rest
  12. call stream filename, C, 'query exists'
  13. if result = "" then
  14. do
  15.     say 'PRINTPS.CMD: Error, cannot find' filename
  16.     exit
  17. end
  18. /* PS file header */
  19. call lineout output, '% PRINTPS.CMD PostScript OUTPUT'
  20. call lineout output, '/cour /Courier findfont 'linesize' scalefont def'
  21. call lineout output, 'cour setfont gsave'
  22. /* read each line, quote characters and then output */
  23. linecount = 0
  24. pagethrow = 0
  25. do until lines(filename)=0
  26.     line = linein(filename)
  27.     if pagethrow then do
  28.         call lineout output, 'showpage grestore gsave'
  29.         pagethrow = 0
  30.     end
  31.     line = quotechar(line, '\', '\')
  32.     line = quotechar(line, '(', '\')
  33.     line = quotechar(line, ')', '\')
  34.     ycoord = pagelength - topmargin - linecount*linesize
  35.     call lineout output, leftmargin ycoord 'moveto ('line') show'
  36.     linecount = linecount + 1
  37.     if linecount = numlines then do
  38.         pagethrow = 1
  39.         linecount = 0
  40.     end
  41. end
  42. if pagethrow | linecount<>0 then call lineout output, 'showpage grestore'
  43. call lineout output /* close output */
  44. exit
  45.  
  46. /* quotechar - returns string with character "quoted" by another character */
  47. /* the quote character is also known as the escape character */
  48. quotechar:
  49. parse arg newline, char, quote
  50. index = pos(char,newline,1)
  51. do while index<>0
  52.     newline = insert(quote,newline,index-1)
  53.     index = pos(char,newline,index+2)
  54. end
  55. return newline
  56.