REXX built-in function
A ready-made REXX function for common jobs such as cutting up text or checking a dataset, called by name with brackets.
Also written SUBSTR, STRIP, WORDS, SYSDSN, LISTDSI, SYSVAR
REXX comes with many built-in functions. You call one by name with its arguments in brackets, and use the result: first4 = SUBSTR(name, 1, 4) takes the first four characters of name.
Many of them work on text, which is most of what REXX does. SUBSTR takes part of a string. LENGTH gives its length. POS finds where one string appears in another. STRIP removes leading and trailing blanks. WORD and WORDS pick out words and count them. LEFT and RIGHT pad or cut a string to a set width. TRANSLATE changes characters. DATE and TIME return the current date and time in many formats.
TSO adds its own functions for mainframe work. SYSDSN checks whether a dataset exists, returning OK if it does. LISTDSI returns a dataset's details, such as its record format and size, in variables. SYSVAR returns facts about the session, such as the user ID. OUTTRAP captures command output.
A short exec that loops through a list of dataset names, checks each with SYSDSN and reports the missing ones is a good first use of these functions.
Where can I learn this hands-on?
Right here, at ZedBank. You take a junior job at a simulated bank and learn each part of the work by doing it, 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.
- Stem variableREXX's array, a variable with a dot in its name used to hold a list such as the lines of a file.
- REXX execA REXX program, stored as a member in a library and run by name from TSO or ISPF.
- OUTTRAPA REXX function that captures the output of TSO commands into a stem variable, so the exec can read it.