[comp.lang.postscript] "Remote" debugging of PostScript

brf@cbnewsi.att.com (bruce.r.fowler) (06/05/90)

Try this for "remote" postscript debugging.  It adds to the Adobe error
handler (Which I can't include here because of the copyright notice, you'll
have to key it in yourself) code which reads input to end-of-file and
then prints out how many lines were read, i.e., how many the PostScript
interpreter *didn't* read.  Then you can pinpoint the line on which the
error occured with your favorite editor.  This minor modification has saved
me a lot of guesswork in debugging Postscript code.  Enjoy.

For those of you who are new to all this, the Adobe Green Book Appendix A
contains an error handler which is loaded onto the printer and stays resident
until the printer in power cycled.  The jobs being tested are then running
in an environment that prints an error message and stack dump on the output
page when an error is detected.  But as presented, the error handler does
not tell you where in the PostScript source you are.

=-=-=-=-=-=-=-=-=-=-=-= =-=-=-=-=-=-=-=-=-=-=-= =-=-=-=-=-=-=-=-=-=-=-=
		% LINES UNREAD modification - B. Fowler 5/30/88
		% Insert after line 114, "} if" and before line 115,
		% "systemdict /showpage get exec" of error handler in Adobe
		% PostScript Language Program Design (Green book) Appendix A
		/gcan 128 string def
		/infil (%stdin) (r) file def
		0 % Count of lines read to eof
		{ %loop
			infil gcan readline
			{ pop 1 add } { pop exit } ifelse
		} loop
		nl (LINES UNREAD: ) prnt prnt
		% End of LINES UNREAD modification
=-=-=-=-=-=-=-=-=-=-=-= =-=-=-=-=-=-=-=-=-=-=-= =-=-=-=-=-=-=-=-=-=-=-=

						      Bruce Fowler
	   AT&T HR 2F-027  (201)615-5559  Dept 51223  feathers!brf
	  +-------------------------------------------------------+
	  |  ***   The Twilight Zone - Love it or Leave it.  ***  |
	  +-------------------------------------------------------+