MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

REXX equivalent of COBOL UNSTRING function

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
pradeepg
Beginner


Joined: 06 Jan 2003
Posts: 25
Topics: 12
Location: Columbus, OH

PostPosted: Thu Aug 25, 2005 10:11 am    Post subject: REXX equivalent of COBOL UNSTRING function Reply with quote

Hello List,

Is there any function available in REXX to unstring the data-field into different variable like COBOL UNSTRING function.

My requirement is to unstring a dataset name into different variables to get the HLQ, MLQ. etc....

Ex: Dataset name is: ABC.XYX.DEF.IJK
I want them in 4 different variables delimited by . (dot).

HLQ should have ABC
MLQ should have XYZ etc.....

Thanks in advance.

- Pradeep
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Thu Aug 25, 2005 10:21 am    Post subject: Reply with quote

For your requirement, you can use the "POS" function followed by the "SUBSTR" function. Check the rexx reference manual for details on how to use the functions. Following is the link -



http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ3A300/CCONTENTS?DT=19960716152726


Regards,
Manas
_________________
There is no path to peace. Peace is the path.
- Mahatma Gandhi (1869-1948)
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Aug 25, 2005 10:29 am    Post subject: Reply with quote

Wouldn't a PARSE command have worked?

dataset_name = 'ABC.XYX.DEF.IJK'
PARSE VAR dataset_name HLQ '.' MLQ '.' THIRDLQ '.' FOURTHLQ .
Back to top
View user's profile Send private message
pradeepg
Beginner


Joined: 06 Jan 2003
Posts: 25
Topics: 12
Location: Columbus, OH

PostPosted: Thu Aug 25, 2005 10:39 am    Post subject: Reply with quote

Thanks superk. You gave me very simple solution. Thats what I was looking for.

- Pradeep
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Thu Aug 25, 2005 11:27 am    Post subject: Reply with quote

Parse is very powerful, and faster than most of the string builtins. If you learn to use it well, you will probably never need to use substr, although you run the risk of writing code that is slightly more difficlut for others to understand.

For example, you can initialize many variables at once:

Parse value 'one two' with v_one V_2 empty_1 empty_2

or you can do substringing

Parse vara leftFiveChars 6 restOfString

or swap variables (assuming no spaces)

Parse val1 val2 with val2 val1

You can even increment a stem variable index and assign the value to the new tail in one line:

parse value (line.0+1) 'new stuff' with 1 x line.x 1 line.0 .
(that last one looks silly, but it can be useful in practice)

Parse is the most misunderstood Rexx feature, but also one of the most powerful.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group