Instructions
The example script uses the say and pull instructions to write information to the screen, and to read user input, respectively. As in any power language, these instructions have many variable-manipulation and formatting options, and they manage input/output for any of many different devices. The example script illustrates simple output to the screen and input from the keyboard.
Rexx has a couple dozen instructions. They include all those necessary for controlling program logic, as shown in Table 3.
Table 3 Rexx Instructions
Instruction |
Use |
call |
Invokes a routine or enables an error condition |
do |
All forms of the do statement (do..while, do..until, do N times, etc.) |
exit |
Ends a program |
if |
All forms of the if statement (if..then, if..then..else, etc.) |
iterate |
Alters the flow of control by passing control directly back to a do instruction |
leave |
Alters the flow of control by passing control out of a do loop |
return |
Returns control to the caller |
select |
Selects a branch from a set of alternatives (implements a "case" construct) |
signal |
Transfers control to a label (similar to a "go to"), or enables or disables an error condition |
Rexx offers the full set of programming constructs required for structured programming. But it also offers common unstructured constructs, should you want them.
Other Rexx instructions manage the environment and perform other tasks, as shown in Table 4.
Table 4 Miscellaneous Instructions
Instruction |
Use |
address |
Dictates the external environment to which the script sends commands |
arg |
Reads input arguments, or parses arguments in a template |
drop |
Unassigns one or more variables |
interpret |
Dynamically evaluates instructions provided in an expression |
nop |
No operation |
numeric |
Controls precision and other aspects of numeric calculation |
options |
Passes commands to the Rexx interpreter (controls the interpreter) |
parse |
Assigns values to variables as a result of controlled parsing |
procedure |
Controls the scoping of variables across routines |
pull |
Reads input and applies parsing rules |
push |
Adds a line to the external data queue or stack in LIFO order |
queue |
Adds a line to the external data queue or stack in FIFO order |
say |
Evaluates an expression and writes a line to the default output stream |
trace |
Manages the built-in debugging facility |