Skip to content
REXX & automation

Stem variable

REXX's array, a variable with a dot in its name used to hold a list such as the lines of a file.

Also written stem, compound variable, REXX array

A stem is how REXX holds collections. A variable whose name ends in a full stop is a stem, and appending an index to it gives an element, so a set of related values shares one name.

The convention that makes them so usable is storing the count in element zero. Many REXX services fill a stem this way. Read a dataset and you get the lines in successive elements, with the number of them in element zero, so looping through the contents is immediate.

They are not limited to numeric indexes. Any value can be used, which turns a stem into a lookup keyed by whatever makes sense: an account number, a name, a code. That makes tables and simple caches easy to build without any declaration.

A whole stem can be given a default value in one assignment, initialising every element that has not been set individually.

Between PARSE for taking text apart and stems for holding the results, most of what a practical REXX exec does is covered.

Browse all 115 terms

Learn this properly.

Use Stem variable for real in Mainframe101, in your browser, with Zed beside you. Join the waitlist.

Early access and updates. No spam, unsubscribe any time.