Controlling the Flow Within an Exec
This chapter introduces instructions that alter the sequential execution of an exec and demonstrates how those instructions are used.
Generally when an exec runs, one instruction after another executes, starting with the first and ending with the last. The language processor, unless told otherwise, executes instructions sequentially.
You can alter the order of execution within an exec by using specific
REXX instructions that cause the language processor to skip
some instructions, repeat others, or jump to another part of the exec.
These specific REXX instructions can be classified as follows:
- Conditional instructions, which set up at least one condition
in the form of an expression. If the condition is true, the language processor selects
the path following that condition. Otherwise the language processor selects
another path. The REXX conditional instructions are:
- IF expression/THEN/ELSE
- SELECT/WHEN expression/OTHERWISE/END.
- Looping instructions, which tell the language processor to repeat
a set of instructions. A loop can repeat a specified number of times
or it can use a condition to control repeating. REXX looping instructions
are:
- DO expression/END
- DO FOREVER/END
- DO WHILE expression=true/END
- DO UNTIL expression=true/END
- Interrupt instructions, which tell the language processor to leave
the exec entirely or leave one part of the exec and go to another
part, either permanently or temporarily. The REXX interrupt instructions
are:
- EXIT
- SIGNAL label
- CALL label/RETURN