A good macro language needs of course flow control. The statements that
take care of the flow control are:
- while/endwhile
- The word `while' should be followed by a blank and then an expression
that is formed according to the above rules for expressions. As
long as this expression evaluates into true the statements between
the `while' and its matching `endwhile' statement will be executed,
otherwise execution continues after the matching `endwhile'
statement.
- if
- The if should be followed by one or more blank spaces and then an
expression. The rules for this expression are identical to the
rules for the expression in the while statement. If the expression
has the logical value true the statements after the if are executed.
If the expression has the value false execution continues either after
a matching else or after a matching endif.
- else
- This statement is used together with an if and an endif statement.
When execution reaches an else statement (without having been sent
there directly from an if statement) the statements between the else
and the matching endif are skipped. When execution reaches the else
because of a `false' expression in an if statement the statements
between the else and the endif will be executed.
- endif
- Needed to terminate a range of statements that come with an if statement.
The occurrence of an if statement without a matching endif statement
is a fatal error: the execution of the macro will be stopped.
An endif statement that is superfluous is ignored.
- goto
- This should be followed by the name of a
label. Control is passed to the statement after the label.
If the label is not found execution of the macro will be halted and
an error message will be given.
- label
- This should be followed by a name which is then interpreted as the
name of the label.
- return `returncode'
- This statement causes the termination of the current macro. This
doesn't generate an error condition as abnormal termination of a
macro would do (like when running into a syntax error). On the other
hand whatever comes after the word `return' is seen as a return
code. It may be a complete expression as in the right hand side of a
`set' command. The result of this expression is put in a dedicated
variable that goes by the name returncode. If no return statement is
used the returncode will be set to an empty string when the macro is
finished. The variable returncode can be used to send information to
the parent process. See also p. .