View previous topic :: View next topic
|
Author |
Message |
chong.zhou
New User
Joined: 31 May 2017 Posts: 9 Location: Czech
|
|
|
|
I'm learning rexx, so my question might be silly. Sorry for that
If I have a STEM variable containing many items, but the keys (a.k.a. the tails) are not necessarily sequential numbers, but perhaps are some key strings.
Can I traverse the STEM and process each item?
Example STEM:
stemVar.1 = 'ascasc'
stemVar.abc = '2353235'
stemVar.567 = 'qju&*j'
...
Can I process each item in stemVar without knowledge of the tail names?
...or,
Is thinking a STEM as a STL container the root cause of my problem?
Thank you in advance! |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
I do not know what an "STL container" is but you should regard stem variables more as arrays. You can traverse the stem if you have another stem variable holding all the tail values - you traverse that one and then access the original.
If you are a beginner in Rexx then you should really be posting in the beginner's forum - I used to do that for all my drsort questions because I am no expert, even to this day, on using sort. |
|
Back to top |
|
|
chong.zhou
New User
Joined: 31 May 2017 Posts: 9 Location: Czech
|
|
|
|
Thank you Nic for your quick response!
So I'll take it as 'no, you can't traverse a stem', because accessing items with keys is not traversal. OK I see now. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
Back to top |
|
|
chong.zhou
New User
Joined: 31 May 2017 Posts: 9 Location: Czech
|
|
|
|
Thank you very much Enrico.
I read through that thread and at least I see that, in REXX, STEMs behave like an array or a map but actually they are not real data containers. A group of items 'in' a STEM is just a series of common variables having the same name prefix. But they are still variables at the same level with other non-STEM variables.
I'll bookmark the thread you mentioned in case I would really need it in the future. Thank you. |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 712 Location: Denmark
|
|
|
|
There is no standard method for scanning through a REXX stem.
I have written a program REXXGBLV to address some of the deficiencies in REXX, like no global pool, and one of the functions is to enumerate a REXX stem.
If you can install a program, or know someone who can, then the program is found at Use [URL] BBCode for External Links file 669, or www.harders-jensen.com/wjtech/programs.html for the newest version. Current version cannot handle stems with numeric suffix, but I am working on a new version which can. |
|
Back to top |
|
|
|