Stem variable
REXX's list: one name with a dot, holding many items.
Also written stem, compound variable, REXX array
Why it matters. A file read into an exec arrives as a list of lines. A stem is where that list lives.
See it
Send the quoted commands below to TSO.
Syntax
stem.tail = value stem. = value EXECIO * DISKR ddname (STEM stem. FINIS
- stem.
- The name with a dot at the end.
- tail
- The part after the dot: a number or any word.
- stem.0
- By habit, the count of items.
- stem. = value
- Give every item that has not been set that value.
- EXECIO ... STEM
- Read a file into a stem. It sets stem.0 to the number of lines.
Try it STEM
- 1
In the exec STEMS, the list is called acct. Items 2 and 3 are set. Write the line that puts ACCT0001 in item 1.
REXX acct.1 = 'ACCT0001' - 2
Run the exec STEMS. It sets acct.0 to the number of items, then shows each one.
EXEC 'ZB0001.DEV.REXX(STEMS)'
Remember
- A stem is a name that ends with a dot: acct. Setting acct. = 0 gives every item the value 0.
- acct.1, acct.2 and acct.3 are its items. The part after the dot can be a number or any word.
- By habit, acct.0 holds how many items there are. EXECIO into a stem sets it for you.
The usual mistake
DO i = 1 TO acct.0 (acct.0 was never set)
acct.0 has no value, so REXX reads it as the text ACCT.0. The loop cannot count to text, and the exec stops with error 41.
Set acct.0 = 3 first, then loop
On real z/OS
MF/OS handles stems as REXX defines them. EXECIO is simplified: DISKRU followed by DISKW rewrites the whole file, and an open is tracked only as a read position.
Where can I practise Stem variable?
Right here, at ZedBank. You take a junior job at a simulated bank and use Stem variable in real work, with Zed beside you. There's nothing to install.
Start at ZedBankRelated
- REXXA readable scripting language used across the mainframe for automation, tooling and quick one-off tasks.
- PARSEREXX's instruction for pulling a string apart into pieces, by position, by delimiter or by pattern.
- REXX execA REXX program, stored as a member in a library and run by name from TSO or ISPF.