
ps string manipulation... ppuulllEEEEEEZZZZZZ
Quote:
> I needed a routine to take two strings and concatenate them into a single
> string. I figured this would be easy. I was wrong.
> The working code I finished with looks like this:
> /concatstr {
> /Addstr exch def
> /Mystr exch def
> /Newstr Mystr length Addstr length add string def
> Mystr Newstr copy length
> Newstr exch Addstr putinterval
> Newstr
> } bind def
> and it works like this:
> (string1 ) (string2 ) concatstr
> leaves (string1 string2 ) on the operand stack.
> I'm not an experienced ps programmer, and I have to believe I'm missing
> something. It CAN'T be that arcane!
> or maybe it can... sheesh.
> Anybody know a simpler way to do this? Please educate me. Thanks.
No, you've pretty much got the idea. If you will have to do more of this
kind of thing, you would probably find Glenn Reid's book "Thinking in
postscript" very helpful. It's available free as PDF file from <http://www.rightbrain.com/pages/books.html>.
Page 140 shows an example procedure called "concatentate," which works
on both strings and arrays. You might find it interesting or useful.
Best regards.