Reputation: 39
Having difficulty trying to create a postscript file that will output differently based on a string at the beginning. I'm able to do the following and create a valid postscript file:
/x (string) def
/Times-Roman findfont
12 scalefont
setfont
newpath
100 200 moveto
(sdbc) show
Then, I try to wrap an if statement around it...
/x (string) def
x (string) eq {
/Times-Roman findfont
12 scalefont
setfont
newpath
100 200 moveto
(sdbc) show } if
And this creates an invalid postscript file. Any tips on postscript syntax to achieve this kind of thing would be greatly appreciated!
I'm using Document Viewer on ubuntu which I believe is used as the interpreter.
Upvotes: 3
Views: 241
Reputation: 39
It was ubuntu's document viewer - it is very touchy. Try using ghostscript if you run into this problem.
Upvotes: 0
Reputation: 31139
String (and other composite) objects are the same only if they are the same object, not if their contents are the same. In C terms they are equivalent only if they are the same pointer.
So:
/x (string) def
/y x def
/Z (string) def
y equals x, z does not equal either x or y. If you want to test for the contents of the strings being the same, then you need to examine the character at each position individually using the get operator, there is no strcmp or similar operator.
The behaviour of composite objects is is an important and often overlooked point in PostScript.
Upvotes: 2