STRING AND UNSTRING and use of it?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
BobP
Registered Member
Posts: 44
Joined: Mon Jun 17, 2013 1:33 pm

STRING AND UNSTRING and use of it?

Post 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,
Thanks,
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: STRING AND UNSTRING and use of it?

Post 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.
BobP
Registered Member
Posts: 44
Joined: Mon Jun 17, 2013 1:33 pm

Re: STRING AND UNSTRING and use of it?

Post 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.
Thanks,
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”