ps string manipulation... ppuulllEEEEEEZZZZZZ 
Author Message
 ps string manipulation... ppuulllEEEEEEZZZZZZ

Hi, all,

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

Quote:
} 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.

Phil Weingart



Mon, 10 Dec 2001 03:00:00 GMT  
 ps string manipulation... ppuulllEEEEEEZZZZZZ

Quote:

>Hi, all,

>I needed a routine to take two strings and concatenate them into a single
>string. I figured this would be easy. I was wrong.

That's about it. It would be more efficient, but even more arcane, if
you avoided defining any variable names.  I've seen solutions using
forall as well, but I doubt they are quicker.
----------------------------------------

Visit http://www.*-*-*.com/ ,
PSAlter, psalters, tea, and small {*filter*} animals. And stuff.  


Mon, 10 Dec 2001 03:00:00 GMT  
 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.



Mon, 10 Dec 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. String manipulation with vbscript

2. String manipulation topic

3. String manipulation

4. String manipulation...

5. String manipulation...

6. Text String Manipulation

7. Newbie question : string manipulation with VBscript.

8. String manipulation

9. String manipulation help

10. Help for a Newbie: CSV data to be used in string manipulation

11. unicode and ANSI string manipulation repost

12. unicode and ANSI string manipulation

 

 
Powered by phpBB® Forum Software