🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #2363

Re: A useful def for self-contained packages

#2363
From: Ben Cranston
Date: Mon, 11 Jun 1990 18:45
47 lines
2412 bytes
I am in the midst of trying to write "the canonical gray letters diagonally
across each page, like DRAFT" postscript program, and stumbled across a real
hairy gotcha.  Thought I would share the problem and solution.

Suppose you want to redefine the meaning of a PostScript verb, but keep access
to the old definition.  For example, you want to redefine showpage to impose
a landscape coordinate system upon each new page.  You can do something like:

/showpage [
    /showpage load
    611.76 0 /translate load 90 /rotate load
] cvx def

this works because "showpage" is an OPERATOR and will be executed when the
interpreter comes across it in the procedure array.  But note well: this kind
of redefinition will only work ONCE because "showpage", after the above, is
a PROCEDURE (array) not an OPERATOR.  One could follow this with:

/showpage [
    /showpage load /exec load
    /otherproc load /exec load
] cvx def

Now, running across showpage merely puts it on the stack, and the exec that
follows it actually runs it.  But, this scheme won't work with the original
OPERATOR showpage because it gets run immediately and the exec dies off with
an empty-stack diagnostic.

This is the only way I've been able to make it work for both cases:

/showpage [
    /showpage load dup type (operatortype) ne {/exec load} if
    /otherproc load /exec load
] cvx def

I'll post the "gray letters diagonally" program later this week, and I'd like
to have some beta testers with weird postscript environments, like the "n-up"
routines that put multiple logical pages on a physical page.  Since I'm using
the "clippath pathbbox" trick for finding the physical page size this beast
should be physical-page-size independant.

It has worked fine for both portrait and landscape anyway...
-- 

"It's all about Power, it's all about Control
 All the rest is lies for the credulous"
-- Man-in-the-street interview in Romania one week after Ceaucescu execution.
Technical Details
Message-ID: <6656@umd5.umd.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!haven!umd5!zben
References: <57234@bbn.BBN.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!haven!umd5!zben
From: zben@umd5.umd.edu (Ben Cranston)
Newsgroups: comp.lang.postscript
Subject: Re: A useful def for self-contained packages
Summary: Another Postscript gotcha!
Message-ID: <6656@umd5.umd.edu>
Date: 11 Jun 90 18:45:47 GMT
References: <57234@bbn.BBN.COM>
Reply-To: zben@umd5.umd.edu (Ben Cranston)
Organization: University of Maryland, College Park
Lines: 47