Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.BERKELEY.EDU Path: utzoo!watmath!clyde!cbosgd!ucbvax!laser-lovers From: laser-lovers@ucbvax.UUCP Newsgroups: mod.computers.laser-printers Subject: Re: Flaw in Postscript? Message-ID: <8601152109.AA04883@adobe.UUCP> Date: Wed, 15-Jan-86 16:09:32 EST Article-I.D.: adobe.8601152109.AA04883 Posted: Wed Jan 15 16:09:32 1986 Date-Received: Mon, 20-Jan-86 04:22:05 EST References: <1029@adobe.UUCP> Sender: daemon@ucbvax.BERKELEY.EDU Organization: Adobe Systems Incorporated, Palo Alto Lines: 78 Approved: laser-lovers@washington.arpa This is in response to a message from LARRY SEILER regarding the PostScript language and the redefining operators, and to some of the subsequent replies. The problem: You want to redefine the `showpage' operator in such a way that a user job downloaded to the PostScript printer will use your version of `showpage' instead of the one in /systemdict, thereby allowing for N-up output, page accounting, etc. You also want to make sure that your version of `showpage' does not replace any existing re-definition of `showpage', but augments it. A solution: The version of /showpage that is in systemdict CANNOT be altered by the user, and will always be the bottom line. Anyone who redefines /showpage in userdict will need to essentially rename the existing /showpage as something else, and then call it. If /showpage has been redefined already, then this routine should be called by the new /showpage as if it were the real showpage. The `exitserver' operator will allow the user (or system manager) to make the operator definition persist from one user job to another, because the definition will take place inside the save/restore construct in the serverloop. There is no other privilege afforded by the `exitserver' operator; the routines in systemdict are in ROM and cannot be altered. If /showpage has not been redefined, then the /showpage in systemdict should be called directly. In order to allow for aribtrary levels of redefinition, a scheme should be used to generate a unique name for the old /showpage (which can be done using the page count, for example, but that is a bit beyond this discussion), then to copy the old showpage under the new name, and call it from the new /showpage you are defining. Below is an example which does not bother to make sure that the name is unique, but otherwise satisfies the problem posed above: %!PS-Adobe-1.0 %%For: redefining the showpage operator /realshowpage /showpage load def /showpage { 90 rotate 0 -612 translate .5 .5 scale realshowpage } def The use of the `load' operator here will look downward through the dictionary stack (in case there are added levels of dictionaries, redefinition, etc. already there) until it finds the `showpage' name, and will push the procedure body onto the stack. In the event that the /showpage routine has not been redefined, then /realshowpage will get the /showpage routine that is in systemdict, which it should. If another job comes along and redefines /showpage again, then it should rename my /realshowpage to something different, and call it the same way: %!PS-Adobe-1.0 %%For: re-redefining the showpage operator /realshowpage.$$ /showpage load def /showpage { 90 rotate 0 -612 translate .5 .5 scale realshowpage.$$ } def In this case, the `/showpage load' will retrieve my version of /showpage from above, which in turn will call /realshowpage, which is actually the /showpage from systemdict. This can go on indefinitely, if you are willing to clutter up userdict with strange names. It basically boils down to a naming problem, not a PostScript problem. Glenn Reid Adobe Systems Incorporated