×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Cobol unstring - is it possible 2 different delimiters?

Cobol unstring - is it possible 2 different delimiters?

Cobol unstring - is it possible 2 different delimiters?

(OP)
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

 

RE: Cobol unstring - is it possible 2 different delimiters?

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

RE: Cobol unstring - is it possible 2 different delimiters?

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
 

RE: Cobol unstring - is it possible 2 different delimiters?

Oops,

I forgot the POINTER in the 1st unstring.

Regards, Jack.

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

RE: Cobol unstring - is it possible 2 different delimiters?

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

RE: Cobol unstring - is it possible 2 different delimiters?

(OP)
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!!!

RE: Cobol unstring - is it possible 2 different delimiters?

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.

RE: Cobol unstring - is it possible 2 different delimiters?

(OP)
My code did work, the 1st unstring was delimited by a space.  The 2nd was delimited by 2 spaces.

Thanks!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close