Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1197 > unrolled thread
| Started by | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| First post | 2012-12-27 18:50 +0100 |
| Last post | 2012-12-27 22:29 +0100 |
| Articles | 3 — 1 participant |
Back to article view | Back to comp.lang.postscript
Popping dict leaves 0 on stack Cecil Westerhof <Cecil@decebal.nl> - 2012-12-27 18:50 +0100
Re: Popping dict leaves 0 on stack Cecil Westerhof <Cecil@decebal.nl> - 2012-12-27 21:20 +0100
Re: Popping dict leaves 0 on stack Cecil Westerhof <Cecil@decebal.nl> - 2012-12-27 22:29 +0100
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2012-12-27 18:50 +0100 |
| Subject | Popping dict leaves 0 on stack |
| Message-ID | <87pq1vidu3.fsf@Compaq.site.inet> |
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?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [next] | [standalone]
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2012-12-27 21:20 +0100 |
| Message-ID | <87licji6wv.fsf@Compaq.site.inet> |
| In reply to | #1197 |
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
[toc] | [prev] | [next] | [standalone]
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2012-12-27 22:29 +0100 |
| Message-ID | <87han7i3p3.fsf@Compaq.site.inet> |
| In reply to | #1197 |
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 was a stupid error from myself. I had a function where I used a start and end value. And when you define end, then end does not anymore what it should do. I changed end to endVal and problem solved. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web