Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 5 Wed Oct 04, 2017 6:54 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 47 Fri Sep 29, 2017 1:08 pm
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us