/MACRO_SYNTAX_Branching |
---|
Macro statements for general flow control.
/MACRO/SYNTAX/Branching/CASE |
---|
Select one of many branches.
The CASE switch evaluates the string expression and compares it one by one against the label lists until the first match is found. If a match is found the statements up to the next label are executed before skipping to the statement following the ENDCASE. None of the statements are executed if there is no match with any label.
Each label is a string constant and the comparison witht the selection expression is case-sensitive. If the same statement sequence should be executed for distinct values a comma-separated list of values can be used.
The "*" character in a label item acts as wildcard matching any string of zero or more characters, i.e., "(*)" constitutes the default label.
/MACRO/SYNTAX/Branching/GOTO_and_IF_GOTO |
---|
Unconditional and conditional branching.
The simplest form of flow control is provided by the GOTO statement which continues execution at the statement following the target "label:". If the jump leads into the scope of a block statement, for example a DO-loop, the result is undefined.
The target may be given by a variable containing the actual label name.
This old-fashioned construct is equivalent to
/MACRO/SYNTAX/Branching/IF_THEN |
---|
Conditional execution of statement blocks.
The general IF construct executes the statements following the first IF/ELSEIF clause for with the boolean expression is true and then continues at the statement following the ENDIF. The ELSEIF clause can be repeated any number of times or can be omitted altogether. If none of the expressions is true, the statements following the optional ELSE clause are executed.
/MACRO/SYNTAX/Branching/ON_ERROR |
---|
Installing an error handler.
Each command returns a status code which should be zero if the operation
was successful or non-zero if any kind of error condition occurred. The
status code can be tested by $IQUEST(1) system function.
installs an error handler which tests the status code after each command
and branches to the given label when a non-zero value is found. The error
handler is local to each macro.
and
are short-hand notations for a corresponding EXITM or STOPM statement at
the targat label.
continues execution with the next command independent of the status code.
This is the initial setting when entering a macro.
An error handler can be deactivated by this statement.
An error handler can be reactivated by this statement.