z/OS TSO/E REXX Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Stems

z/OS TSO/E REXX Reference
SA32-0972-00

A stem is a symbol that contains just one period, which is the last character. It cannot start with a digit or a period.

These are stems:
FRED.
A.

By default, the value of a stem is the string consisting of the characters of its symbol (that is, translated to uppercase). If the symbol has been assigned a value, it names a variable and its value is the value of that variable.

Further, when a stem is used as the target of an assignment, all possible compound variables whose names begin with that stem receive the new value, whether they previously had a value or not. Following the assignment, a reference to any compound symbol with that stem returns the new value until another value is assigned to the stem or or that stem or individual variable is dropped.

For example:
hole.  = "empty"
hole.9 = "full"
hole.rat = "full"
rat = "cheese"
drop hole.rat
say hole.1 hole.mouse hole.9 hole.rat
/* says "empty empty full HOLE.cheese" */
Thus, you can give a whole collection of variables the same value. For example:
total. = 0
do forever
   say "Enter an amount and a name:"
   pull amount name
   if datatype(amount)='CHAR' then leave
   total.name = total.name + amount
   end
You can always obtain the value that has been assigned to the whole collection of variables by using the stem. However, this is not the same as using a compound variable whose derived name is the same as the stem. For example:
total. = 0
null = ""
total.null = total.null + 5
say total. total.null              /* says "0 5" */
You can manipulate collections of variables, referred to by their stem, with the DROP and PROCEDURE instructions. DROP FRED. drops all variables with that stem (see page DROP), and PROCEDURE EXPOSE FRED. exposes all possible variables with that stem (see page PROCEDURE).
Note:
  1. When the ARG, PARSE, or PULL instruction or the VALUE built-in function or the Variable Access Routine (IRXEXCOM) changes a variable, the effect is identical with an assignment. Anywhere a value can be assigned, using a stem sets an entire collection of variables.
  2. Because an expression can include the operator =, and an instruction can consist purely of an expression (see Commands to external environments), a possible ambiguity is resolved by the following rule: any clause that starts with a symbol and whose second token is (or starts with) an equal sign (=) is an assignment, rather than an expression (or a keyword instruction). This is not a restriction, because you can ensure the clause is processed as a command in several ways, such as by putting a null string before the first name, or by enclosing the first part of the expression in parentheses.
    Similarly, if you unintentionally use a REXX keyword as the variable name in an assignment, this should not cause confusion. For example, the clause:
    Address='10 Downing Street';
    is an assignment, not an ADDRESS instruction.
  3. You can use the SYMBOL function (see SYMBOL) to test whether a symbol has been assigned a value. In addition, you can set SIGNAL ON NOVALUE to trap the use of any uninitialized variables (except when they are tails in compound variables—see page Conditions and condition traps).

REXX symbol and hexadecimal code cross-reference shows the REXX symbols and their hexadecimal values as found in the U.S. Code Page (037).

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014