MainframeSupports
tip week 42/2001:

Internal tables in REXX are called stems. Tables as we know them in COBOL, CSP/VAG, PL/1 and C/C++ doesn't exist. Stems are far more flexible as we will see in this tip.

The following REXX will print the extension phone number for the person, who is supplied as input:

/* REXX */
/* MY NAME IS: EXTPHONE */
ARG PERSON
EXTPHONE. = 'NOT AVAILABLE'
EXTPHONE.LARRY = 213
EXTPHONE.THEBOSS = 300
EXTPHONE.JOHN = 819
EXTPHONE.HELPDESK = 911
EXTPHONE.ANNE = 727
SAY 'EXT. PHONENO FOR ' !! PERSON !! ' IS ' !! EXTPHONE.PERSON
EXIT

This REXX can be invoked simply by typing in TSO EXTPHONE THEBOSS. The table or more correct the stem is named EXTPHONE and the elements in the table has names instead of numbers. You can use numbers similar to most other programming language. One of the smart parts about stems are, that you can supply a default value for all the entries in the table that doesn't exist, in this example it is 'NOT AVAILABLE'.

If the REXX EXTPHONE is called with a value, that REXX doesn't allow as a variable name then the REXX will fail. To avoid this from happening you must validate the contens of variable PERSON. You can read more about stems and allowed names in stems in the REXX reference manual, which is part of the TSO manuals.

Previous tip in english        Sidste danske tip        Tip list