Article View: comp.lang.postscript
Article #8529Re: The // operator
From: Antti Louko
Date: Tue, 06 Jun 1989 07:56
Date: Tue, 06 Jun 1989 07:56
79 lines
2727 bytes
2727 bytes
In article <3903@imagen.UUCP> geof@apolling (Geof Cooper) writes:
>Software developers, be careful how you use this feature. It is not
>possible to test for the existence of a feature if you want to use // in
>relation to it. For example, the latest Apple LaserPrep contains code
>of the form:
>
> if <I'm a LaserWriter> then
> <do some nifty things with funny operators in serverdict>
>
>This is all very well, but the "nifty thing" references LaserWriter
>operators in serverdict using the // convention. This means that those
>names must resolve to valid objects on ALL machines, not just the
>LaserWriter, since the names are resolved in the scanner independent
>of the result of the conditional.
>
>- Geof
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) ==
--------------------------------
Technical Details
Message-ID:
<22580@santra.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!kth!draken!tut!santra!kampi.hut.fi!aloReferences:
<3903@imagen.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!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 Lines: 79