PARSE
REXX's instruction for pulling a string apart into pieces, by position, by delimiter or by pattern.
Also written PARSE VAR, PARSE ARG
PARSE is the instruction that makes REXX so effective at handling text, and it is the feature people miss most in other languages.
Instead of writing code to search and slice a string, you describe the shape you expect and name the parts. Splitting a line into fields separated by spaces is one instruction with a list of variable names. Splitting on a particular character means putting that character in the template. Taking fixed columns means giving positions.
Its variants cover where the text comes from. Parsing the argument handles what was passed to the exec. Parsing a variable takes apart something already in hand. Parsing the value of an expression works on a result directly. There is also a form that reads a line typed by the user.
Because so much mainframe work involves reading command output, listings and records with fixed layouts, this comes up constantly. An exec that runs a command, parses the output and acts on what it found is the shape of a great deal of practical automation.
Related terms
- REXXA readable scripting language used across the mainframe for automation, tooling and quick one-off tasks.
- REXX execA REXX program, stored as a member in a library and run by name from TSO or ISPF.
- Stem variableREXX's array, a variable with a dot in its name used to hold a list such as the lines of a file.
- TSO commandA command typed at a TSO prompt or on an ISPF command line to ask the system to do something directly.