From: Cecil Westerhof Newsgroups: comp.lang.postscript Subject: Re: Popping dict leaves 0 on stack Organization: Decebal Computing References: <87pq1vidu3.fsf@Compaq.site.inet> X-Homepage: http://www.decebal.nl/ Date: Thu, 27 Dec 2012 21:20:16 +0100 Message-ID: <87licji6wv.fsf@Compaq.site.inet> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:fvtVLxRzNiHRslq0XemCzKQByBg= MIME-Version: 1.0 Content-Type: text/plain X-Complaints-To: abuse@xennanews.com Lines: 67 NNTP-Posting-Host: 84.53.123.169 (84.53.123.169) NNTP-Posting-Date: Thu, 27 Dec 2012 21:29:06 +0100 Path: csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.astraweb.com!border6.a.newsrouter.astraweb.com!feed.xsnews.nl!border-3.ams.xsnews.nl!feeder.xennanews.com!nf36.xennanews.com!not-for-mail Xref: csiph.com comp.lang.postscript:1199 Op donderdag 27 dec 2012 18:50 CET schreef Cecil Westerhof: > When I execute the following (with p2pdf): > 5 dict begin > end > > There is an extra zero on the stack. Because of that, I now use the > following code: > 5 dict begin > end pop > > Is this an error in ps2pdf? It is a little bizarre. Sometimes it is necessary and sometimes not. And sometimes it depends on if another end put something on the stack. I have the following function: /centerString { % msg [gray] x y 4 dict begin /y exch def /x exch def dup type /integertype eq { /gray exch def } { /gray -1 def } ifelse /msg exch def x y moveto msg stringwidth pop -2 div 0 % optional: textheight -2 div rmoveto msg gray doShow (3 centerString) == pstack end (leave centerString) == pstack } def When another function put something on the stack with the end of a dict, the same value is put on the stack after the end. But when I put myself something on the stack, this does not happen. I'll try to make a short script to demonstrate it. This function seems to always leave something on the stack after the end, so I put a pop into it: /rectangle { % left bottom right top 4 dict begin /top exch def /right exch def /bottom exch def /left exch def left bottom moveto right bottom lineto right top lineto left top lineto left bottom lineto closepath end pop } def -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof