Syntax
BD>...
BD>...Body of commands
BD>...
BD>...
BD>...Body of commands
BD>...
BD>...
BD>...Body of commands
BD>...
BD>if : E command command ... else : command command ...
E is any valid equation.
These constructions are used to make program flow conditional on some
aspect defined by the user. The value of the equation E is used to
decide upon the appropriate course of action. In the context of
if-then-else constructions, an equation is defined to be TRUE if the
rounded value of the equation is equal to unity, and FALSE otherwise
(the kind of rounding is defined in Appendix A).
Therefore, if the value of the equation following the IF:
command is equal to unity, the body of commands immediately following
will be processed.
The first and second forms of the syntax are
our standard implementations, and the remaining two are more limited,
but rather simpler, implementations designed to avoid some of the
problems that arise from [B/D] being an interpreted language.
If the first form of the syntax is used, if the equation is TRUE, then
the body of commands up to the ENDIF: command is processed in
the usual way. If, however, the equation is false, none of the commands
between the IF: and ENDIF: are processed. In either
case, the ENDIF: command terminates the construction.
If the second form of the syntax is used, if the equation is TRUE, then
the body of commands up to the ENDIF: command is processed in
the usual way. If, however, the equation is false, none of the commands
between the IF: and ENDIF: are processed and instead the
body of commands between the ELSE: and ENDIF: commands
are processed. In either case, the ENDIF: command terminates the
construction.
The final two forms of the syntax are special forms, which we will call
one-line IF: statements. They consist of the IF:
statement, together with one or more commands separated by the symbol
` ', on the same line. The fourth form shows that the ELSE:
command may be included to provide an alternative set of commands to
process if the condition turns out to be FALSE. Notice that the
ENDIF: command is not (and may not) used to mark the end of the
loop: the end-of-line marker does this instead.