[comp.lang.postscript] best method of commenting out blocks of postscript?

seth@miro.Berkeley.EDU (Seth Teller) (03/06/90)

will someone please mail me the results of the discussion a while back
as to the best way of commenting out blocks of postscript code?  i have
much huge postscript output and would like to avoid putting %'s 
everywhere.

thanks much,

seth teller
seth@miro.berkeley.edu

jeynes@adobe.COM (Ross A. Jeynes) (03/06/90)

In article <22649@pasteur.Berkeley.EDU> seth@miro.Berkeley.EDU (Seth Teller) writes:
>will someone please mail me the results of the discussion a while back
>as to the best way of commenting out blocks of postscript code?  i have
>much huge postscript output and would like to avoid putting %'s 
>everywhere.

I pulled this tidbit off the net a while ago; is this what you're trying
to do?

---------------
From decwrl!sun-barr!cs.utexas.edu!uunet!mcvax!kth!draken!tut!santra!kampi.hut.fi!alo Tue Jun  6 17:31:44 PDT 1989
Article 1202 of comp.lang.postscript:
Path: adobe!decwrl!sun-barr!cs.utexas.edu!uunet!mcvax!kth!draken!tut!santra!kampi.hut.fi!alo
>From: alo@kampi.hut.fi (Antti Louko)
Newsgroups: comp.lang.postscript
Subject: Re: The // operator
Message-ID: <22580@santra.UUCP>
Date: 6 Jun 89 07:56:01 GMT
References: <3903@imagen.UUCP>
Sender: news@santra.UUCP
Reply-To: alo@kampi.hut.fi (Antti Louko)
Organization: Helsinki University of Technology, Finland

[-discussion deleted-]

Software developers, you can use this little hack I just put together:
skipblock is a procedure which skips a %%BeginProcSet .. %%EndProcSet
region so that the interpreter won't scan the skipped text.

The only problem is how to get big companies to use this procedure...

    Antti

--------------------------------
%!

%%BeginProcSet: skipblock 1.0 0
/stoppedreadline {
  /savedhandler errordict /rangecheck get def
  errordict /rangecheck { pop stop } put
  { readline } stopped
  errordict /rangecheck /savedhandler load put
  { exch pop true dup }
  { false }
  ifelse
} bind def

/readlinehead {
  /-str- exch def
  /-file- exch def
  -file- -str- stoppedreadline
  {
    {
      -file- (..............) stoppedreadline not
      { pop pop exit} if
      pop pop
    } loop
  } if
} bind def

/skipblock {
  /-save- save def
  /str 600 string def
  /str2 600 string def
  currentfile str readlinehead not { stop } if
  (%%BeginProcSet:) anchorsearch
  { pop /-name- exch def } { stop } ifelse
  {
    currentfile str2 readlinehead not { stop } if
    (%%EndProcSet:) anchorsearch
    { pop -name- eq { exit } if } { pop } ifelse
  } loop
  -save- restore
} bind def
%%EndProcSet: skipblock 1.0 0

%example

skipblock
%%BeginProcSet: foobar
(This stuff should be skipped) ==
(This stuff should be skipped) ==
(This stuff should be skipped) ==
(This stuff should be skipped) ==
%%EndProcSet: foobar
(This stuff should not be skipped) ==
--------------------------------
>From: alo@kampi.hut.fi (Antti Louko)

---------------
Ross Jeynes              
Developer Support                                   jeynes@adobe.com
Adobe Systems Incorporated                 {sun|decwrl}!adobe!jeynes

woody@rpp386.cactus.org (Woody at Eagle Signal) (03/06/90)

In article <22649@pasteur.Berkeley.EDU>, seth@miro.Berkeley.EDU (Seth Teller) writes:
> will someone please mail me the results of the discussion a while back
> as to the best way of commenting out blocks of postscript code?  i have
> much huge postscript output and would like to avoid putting %'s 
> everywhere.
> 
> thanks much,
> 
> seth teller
> seth@miro.berkeley.edu

Do me a favor, and if you get it, email it to me.  I'll see if I can
abstract it to 2 -4 lines for the auto...
Cheers
Woody
C

woody@chinacat.Lonestar.ORG (Woodrow Baker) (03/07/90)

This is a message from my new home base.
sorry for the post, but gotta find out if it works.
Cheers
Woody

woody@chinacat.Lonestar.ORG (Woodrow Baker) (03/07/90)

Remember that the NEC 890 throws the comments away at the
serial input routine.  That is, if you test a line for a
comment, you will never see it on the NEC 890.  On other printers
it will cause Cassidy and Green fonts to fail.  It might also
effect block commenting structures.
Cheers
Woody
r
printers it will.  This causes Century Software fonts to wokn

glenn@heaven.woodside.ca.us (Glenn Reid) (03/08/90)

In article <1035@chinacat.Lonestar.ORG> woody@chinacat.Lonestar.ORG (Woodrow Baker) writes:

>Remember that the NEC 890 throws the comments away at the
>serial input routine.  That is, if you test a line for a
>comment, you will never see it on the NEC 890.

Nonsense.  The language scanner throws away comments, not the serial
processor.  If you read the input stream as DATA (as with "readline"
or "readstring"), you will get every single byte, including comments.

Glenn Reid

woody@chinacat.Lonestar.ORG (Woodrow Baker) (03/08/90)

In article <153@heaven.woodside.ca.us>, glenn@heaven.woodside.ca.us (Glenn Reid) writes:
> In article <1035@chinacat.Lonestar.ORG> woody@chinacat.Lonestar.ORG (Woodrow Baker) writes:
> 
> >Remember that the NEC 890 throws the comments away at the
> >serial input routine.  That is, if you test a line for a
> >comment, you will never see it on the NEC 890.
> 
> Nonsense.  The language scanner throws away comments, not the serial
> processor.  If you read the input stream as DATA (as with "readline"
> or "readstring"), you will get every single byte, including comments.

Sorry about this..but...I recently had to deal with a client with a local
printshop. This lady has a NEC-890.  She had just purchased ALL of
Cassidy and Greene's fonts.  Nearly $1000.00.  She could not get them to
work.  What would happen was this..The first time you downloaded a font
it would work.  After that if you downloaded ANY other Cassidy & Greene
font it failed.  It would hang.  I finaly traced the problem to the
following.  There was a preamble in the font.  It was ended with aline
like
%%%%%% end preamble
In order to avoid haveing to download the preamble the fonts would scan
the incoming stream, throwing away everything until it got to the
%%%%%% string.  This had the effect of throwing the preamble out.  Why
they did this, is anyones guess.  What happened was this:  on a QMS
or Apple printer, you could download fonts all day long, and everything
worked fine.  BUT on the NEC-890 the %%%%%%% line never was found.  Infact
NONE of the comment lines got through.  The preamble code would not find them
and just kept throwing the font away.  The preamble code first of all
checked for it's self in memory.  if it was not there, then it skipped
this routine and downloaded the font.  IF this sounds strange, it is.
I finaly worked around it.  This has been reported to C&G, and I
reported it to Adobe via usenet.  I got a message back to the effect that
the "bug report" (even though I didn't call it a bug) had been passed on
to the appropriate person.

As unbelievable as it sounds, it's true.
Glenn, please check things out first before labeling things as nonsense.
I can provide verification of this problem.  It DOES exist.
Cheers
Woody

P.S.  As far as I know, C&G has fixed the problem on thier end, though I
could not swear to it.

batcheldern@hannah.enet.dec.com (Ned Batchelder) (03/16/90)

How about prefacing the block with

	save (

and postfacing (?!) the block with

	) pop restore

This is much simpler than the procset posted, and works with a few
restrictions:

1. You can't comment out more than 64K characters
2. You need to have enough VM available to store the commented characters
3. You need to have space on the operand stack for two objects
4. You need to have one save level available

Those don't seem too harsh.

Ned Batchelder, Digital Equipment Corp., BatchelderN@Hannah.enet.DEC.com