Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cobol unstring - is it possible 2 different delimiters? 1

Status
Not open for further replies.

nixie21

Programmer
Jul 19, 2005
16
US
Here is my problem.

I have a file the field in question looks like this

13 main st
134 red rd
2 main road
952A north land

I want the 1st part in one field and the 2nd in another. I can not do unstring delimited by ' ' because the second field will only have the 1st word.

I then tried this:

unstring c-addr
into pacc-house-no delimited by ' '
pacc-street-name delimited by ' '.
But this is not correct.

What can I do if anything?

Thanks so much

 
Try changing this:
pacc-street-name delimited by ' '.
to this:
pacc-street-name delimited by '~'.
 
Hi,

If your compiler supports reference modification, you might try 2 unstrings or one followed by a ref moded move.

In either case the 1st unstring uses POINTER. Use the pointer to ref mod the 2nd unstring or the move, e.g.:

1st unstring addr-fld delimited by ' ' into st-nbr
2nd unstring addr-fld(ptr:) delimited by size into st-name
or
move addr-fld(ptr:) to st-name

The syntax may be off and I haven't tested, but it's worth a try

Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
Oops,

I forgot the POINTER in the 1st unstring.

Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
Hi nixie21,
This will work (compiler allowing):
Code:
INSPECT WV-FIELD1 REPLACING FIRST ' ' BY '@'
UNSTRING WV-FIELD1
 DELIMITED BY '@'
 INTO WV-FIELD2
      WV-FIELD3

Marc
 
Thanks for the replies. I was able to get it to work with the following code:

move 0 to ws-pos1.
unstring c-addr delimited by ' '
into pacc-house-no count in ws-pos1.

add 1 to ws-pos1.
unstring c-addr delimited by ' '
into pacc-street-name
with pointer ws-pos1.

Learn something new everyday!!!
 
pacc-street-name will end up with one word only with the way you have coded the second UNSTRING. Is that what you want?
In your samples, "952A north land" will have "north" in pacc-street-name. Wouldn't you want "north land"? If so, Jack's second UNSTRING or MOVE would do the trick.
 
My code did work, the 1st unstring was delimited by a space. The 2nd was delimited by 2 spaces.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top