Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Need to loop & extract from variable using parse and substr

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

Active User


Joined: 15 Dec 2005
Posts: 264

PostPosted: Thu Jan 10, 2019 11:42 pm    Post subject: Need to loop & extract from variable using parse and substr
Reply with quote

Hi all

I will receive user input like

Offset='1:20,30:10,40:15,60:70'

I tried the below piece of code

Code:

/*****REXX****/
say 'Enter the offset and length value like:(1:20,30:15,40:15)'
Pull offst
offset1=strip(offst)
cnt1=find(offset1,',')
if cnt1=0 then
do
parse value offset1 with o1 ':' l1
end
if cnt1=1 then
do
pos1=pos(',',offset1)
pos2=pos1-1
str1=substr(offset1,1,pos2)
str2=substr(offset1,pos1 +1)
parse value str1 with o1 ':' l1
parse value str2 with o2 ':' l2
end
.
.
.




I will try trace option to fix the code , but is there any alternate function to
extract the value? Please share. I need to get 1:20 as o1=1 and l1=20 Dynamically from user input.
Back to top
View user's profile Send private message

enrico-sorichetti

Senior Member


Joined: 14 Mar 2007
Posts: 10690
Location: italy

PostPosted: Fri Jan 11, 2019 2:13 am    Post subject: Reply to: Need to loop & extract from variable using parse and substr
Reply with quote

Code:

/* Rexx */
data  = "01:20,30:15,40:15"
do  while data \= ""
    parse var data tokn "," data
    parse var tokn head ":" tail
    say tokn head tail
end
Back to top
View user's profile Send private message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 264

PostPosted: Fri Jan 11, 2019 12:35 pm    Post subject:
Reply with quote

Thanks enrico.i will test and let you know
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 PARSE using REPEAT jerryte DFSORT/ICETOOL 1 Tue Jun 23, 2020 1:58 am
This topic is locked: you cannot edit posts or make replies. Cobol db2 program going in loop sivasaras COBOL Programming 4 Sat Feb 29, 2020 7:44 pm
No new posts To extract the records after the firs... saikarthik94 JCL & VSAM 5 Thu Feb 20, 2020 7:00 pm
No new posts COBOL - Array result in single variab... vinu78 COBOL Programming 3 Thu Feb 20, 2020 5:29 pm
No new posts Variable tso ISR Renato Zangerolami TSO/ISPF 4 Fri Feb 07, 2020 7:30 pm

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