[comp.lang.postscript] String Concatination

nelson@sun.soe.clarkson.edu (Russ Nelson) (05/13/91)

%% string1 string2 append string
% appends two strings
/append {
	2 copy length exch length add	% find the length of the new.
	string dup
% string1 string2 string string
	4 2 roll
% string string string1 string2
	2 index 0 3 index
% string string string1 string2 string 0 string1
	putinterval	% stuff the first string in.
% string string string1 string2
	exch length exch putinterval
} bind def
--
--russ <nelson@clutx.clarkson.edu> I'm proud to be a humble Quaker.
Clear cutting is criminal, spiking trees is criminal, and using hyperbole of
this magnitude in a serious discussion is criminal.  -- Irv Chidsey

mikec@wam.umd.edu (Michael D. Callaghan) (05/13/91)

This is really odd...I'm scanning through the Red Book, and I still
cannot figure it out.

I have two strings, say firstname and lastname.
I want to make them into one,  say fullname.

I can't figure out how to do this! It's driving me nuts!

HELP!

MikeC

-- 
---------------------------------------------------------
Michael D. Callaghan, MDC Designs, University of Maryland
---------------------------------------------------------
	- Celibacy is a curable condition -

toms@fcs260c2.ncifcrf.gov (Tom Schneider) (05/14/91)

In article <1991May12.223939.14987@wam.umd.edu> mikec@wam.umd.edu
(Michael D. Callaghan) writes:

>I have two strings, say firstname and lastname.
>I want to make them into one,  say fullname.

Look on page 106: String operators.  You should be able to construct what you
want (some what awkwardly) using the copy and length functions.  (Or get/put or
getinterval/putinterval.)  Maybe someone else has already devised a simple
'concat' function?

  Tom Schneider
  National Cancer Institute
  Laboratory of Mathematical Biology
  Frederick, Maryland  21702-1201
  toms@ncifcrf.gov

glenn@heaven.woodside.ca.us (Glenn Reid) (05/15/91)

Tom Schneider writes
> In article <1991May12.223939.14987@wam.umd.edu> mikec@wam.umd.edu
> (Michael D. Callaghan) writes:
> 
>                        Maybe someone else has already devised a simple
> 'concat' function?

If you do (and lots of us have), please don't name it `concat', even
though that would be a nice name for it.  There's already a PostScript
operator named `concat', and other programs that don't use bind (smiley
for those following the bind thread:-) might invoke your procedure
by mistake.

--
 Glenn Reid				RightBrain Software
 glenn@heaven.woodside.ca.us		NeXT/PostScript developers
 ..{adobe,next}!heaven!glenn		415-326-2974 (NeXTfax 326-2977)