IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to dynamically assign different variable to store data ?


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Sep 10, 2014 6:32 pm
Reply with quote

Hi,

I got the following input , I have the rexx to store the first colum data according to the same second colum . But my question is that each time the number of these data is changed , is anyway to dynamically assgin the different variable to store first colum data by same second colum instead of write lots of select (Variable name1....n )each time ?

Thank you so much !

Input :
Code:
INP01A 01
OUT01A 01
OUT01B 01
OUT01C 01
OUT01D 01
OUT01E 01
INP02A 02
OUT02A 02
INP03A 03
OUT03A 03
OUT03B 03
OUT03C 03
INP06A 06
OUT06A 06
INP07A 07
OUT07A 07
INP08A 08
OUT08A 08


My code :

Code:
DO CU=1 TO Q                             
   DROP STEPNAME                         
   PARSE VALUE STEP.CU WITH STEPNAME TYPE                   
     SELECT                               
         WHEN TYPE='01' then           
              NAME1 = STEPNAME             
         WHEN TYPE='02' then           
              NAME2 = STEPNAME   
         WHEN TYPE='03' then           
              NAME3 = STEPNAME   
         WHEN TYPE='04' then           
              NAME4 = STEPNAME      ----- and so on .
         END                             
         OTHERWISE                       
     END                                 
   END                                   
                               
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 10, 2014 6:46 pm
Reply with quote

You've already managed one stem variable, why not another?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Sep 10, 2014 7:32 pm
Reply with quote

Use the INTERPRET instruction:
Code:
INTERPRET "NAME"TYPE" = STEPNAME"

This will assign values to NAME01, NAME02 and so on.
You'll have to take care of the zero if you don't want it.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Sep 10, 2014 7:38 pm
Reply with quote

In addition:
  • You don't need to DROP STEPNAME.
  • I would add a period (.) after TYPE in the PARSE line.
  • To do nothing (in the OTHERWISE), use NOP.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Sep 10, 2014 7:44 pm
Reply with quote

Bill Woodger wrote:
You've already managed one stem variable, why not another?
Panels can't handle stem vars. Maybe that's the reason ?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 10, 2014 7:58 pm
Reply with quote

Maybe, but I was thinking since they'd not complained about this:

Code:
PARSE VALUE STEP.CU WITH STEPNAME TYPE


then there shouldn't be a problem.

/understatement on
Knowing a bit more about what the aim of the thing is would help, as always
/understatement off
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Wed Sep 10, 2014 9:45 pm
Reply with quote

Hi Marso,

Really apprecaite your answer. I changed the code according to your suggestion

Code:
 DO CU=1 TO Q                             
 DROP STEPNAME                             
    PARSE VALUE STEP.CU WITH STEPNAME TYPE
    INTERPRET "NAME"TYPE".CU = STEPNAME"   
 END     


It does the job and another thing is i need these data to be stored in the array variable ,so i made "NAME"TYPE".CU. But when i print out the variable Name01 , it looks like following.
1. How to correct this ? i don't want NAME01.*, i only want it has actual data.
2. How to get total number of input in Name** variable ?

Thank you for your help!

Code:
INP01A
OUT01A
OUT01B
OUT01C   
OUT01D   
OUT01E   
NAME01.7
NAME01.8
NAME01.9
NAME01.10
NAME01.11--- and so on
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Sep 10, 2014 11:01 pm
Reply with quote

Presumably you have something which was used to stuff the data into STEP. so why don't you use that instead of the ravishingly descriptive Q?
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2545
Location: Silicon Valley

PostPosted: Thu Sep 11, 2014 9:16 pm
Reply with quote

Quote:
But when i print out the variable Name01...

Show us the code for printing.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Sep 15, 2014 2:14 pm
Reply with quote

Do I really have to quote myself ?
Marso wrote:
In addition:
  • You don't need to DROP STEPNAME.
  • I would add a period (.) after TYPE in the PARSE line.
  • To do nothing (in the OTHERWISE), use NOP.

Now that makes less sense:
jackzhang75 wrote:
i need these data to be stored in the array variable ,so i made "NAME"TYPE".CU.
If you can use stems. why not use NAME.TYPE.CU
When I have a case like this, I also keep a list of the allocated values:
Code:
If WordPos(TYPE,TYPElist) = 0 Then
   TYPElist = TYPElist TYPE
Code:
Do Z = 1 To Words(TYPElist)
   curTYPE = Word(TYPElist,Z)
   Say '<'NAME.curTYPE.CU'>'
End

And one more tip: when displaying a variable, place it around special signs:
Code:
Say "NAME.TYPE.CU=<"NAME.TYPE.CU'>'
Like this you'll see exactly the contents of the variable
(hint inside the tip: in stems, trailing spaces count...)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
No new posts Check data with Exception Table DB2 0
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top