Page 1 of 1

STRING AND UNSTRING and use of it?

Posted: Wed Sep 04, 2013 4:52 pm
by BobP
Hi,

I've never worked with strings, I've looked at IBM reference but it looks like a reference material not like a tutorial to understand it. Can u please tell me the syntax for STRING AND UNSTRING and how can we use it?

Thanks,

Re: STRING AND UNSTRING and use of it?

Posted: Wed Sep 04, 2013 6:10 pm
by Robert Sample
The syntax is best retrieved from the COBOL Language Reference manual.

STRING is used to combine different variables into one variable. Example: if you have a parsed US address (which consists of street number, street prefix, street name, street suffix) the STRING command could be used to create one address line variable that has all of these values in sequence.

UNSTRING takes a variable and breaks it into some number of other variables. Example: if you have a comma-delimited file, the UNSTRING command could be used to split each record into the various variables that make up the line.

Neither STRING nor UNSTRING are mandatory -- the function of both commands can be replicated by use of arrays or reference modification, but if STRING / UNSTRING meet your requirements then they can simplify your code.

Re: STRING AND UNSTRING and use of it?

Posted: Sun Sep 08, 2013 6:11 pm
by BobP
Thanks Robert - I'm working on it and will get back to you with updates. Thanks for explaining, manuals making better sense now.