Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

TSO/E-REXX - parsing strings - could use some help

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
nuck

New User


Joined: 09 Dec 2005
Posts: 33

PostPosted: Wed May 09, 2007 5:33 pm    Post subject: TSO/E-REXX - parsing strings - could use some help
Reply with quote

hey all,

I'm trying to find a good method to parse data out of a long string - I usually use index and substr, but I think that PARSE would be a better alternative. Problem is, I don't know how to use parse properly for something like this.

examples of string that I want to analyze:
1)#JI,ID=32
2)#JI,ID=(10-23,29,31,32)
3)#JI,ID=(10-22)
4)#JI,ID=10
5)#JI,ID=(10,11,12,13,14,15,16,17,18,19,20,21,22)
6)#JI,ID=(29,31,32)

I want to extract the numbers from the above strings. They will be used as subscripts for a stem variable at a later point.
To continue the example, the desired output would be
1)sub.1=32
2)sub.1=10,
sub.2=11,
sub.3=12
....
sub.14=23
sub.15=29
sub.16=31
sub.17=32
... and so on...

I'm gonna go ahead and try use index,substr, and delstr but from what I've heard/read PARSE is a much better way to do this. Anybody feel like pointing me in the right direction?

much thanks

PS: yeah, I know converting the string "10-23" into a 14 element stem has to be done with programming logic and can't be done thru PARSE.
Back to top
View user's profile Send private message

ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu May 10, 2007 11:07 am    Post subject:
Reply with quote

Here is something to start with:
Code:
/* REXX */                                             
                                                       
STR = "#JI,ID=(10,11,12,13,14,15,16,17,18,19,20,21,22)"
                                                       
STR = TRANSLATE(STR,' ','#JI,ID=()')                   
                                                       
SAY STR                                                 
                                                       
EXIT                                                   
                                                       


O.
Back to top
View user's profile Send private message
nuck

New User


Joined: 09 Dec 2005
Posts: 33

PostPosted: Thu May 10, 2007 11:13 am    Post subject:
Reply with quote

thanks,

that's a good tip - it didn't even cross my mind to use translate.
Back to top
View user's profile Send private message
nuck

New User


Joined: 09 Dec 2005
Posts: 33

PostPosted: Thu May 10, 2007 11:28 am    Post subject:
Reply with quote

got it....

STR = "#JI,ID=(10,11,12,13,14,15,16,17,18,19,20,21-29)"

STR = TRANSLATE(STR,' ','#JI,ID=()')

SAY STR
cnt=0
do until str=''
cnt=cnt+1
parse var str shid.cnt str
say shid'.'cnt'='shid.cnt ' str=' str
end
EXIT

results in:
10 11 12 13 14 15 16 17 18 19 20 21-29
SHID.1=10 str= 11 12 13 14 15 16 17 18 19 20 21-29
SHID.2=11 str= 12 13 14 15 16 17 18 19 20 21-29
SHID.3=12 str= 13 14 15 16 17 18 19 20 21-29
SHID.4=13 str= 14 15 16 17 18 19 20 21-29
SHID.5=14 str= 15 16 17 18 19 20 21-29
SHID.6=15 str= 16 17 18 19 20 21-29
SHID.7=16 str= 17 18 19 20 21-29
SHID.8=17 str= 18 19 20 21-29
SHID.9=18 str= 19 20 21-29
SHID.10=19 str= 20 21-29
SHID.11=20 str= 21-29
SHID.12=21-29 str=
***

perfect!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us