IF [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
IF
IF is an HP Pascal Option.
The IF compiler option specifies code to be compiled conditionally,
depending on the value of a Boolean expression.
Syntax
$IF 'Boolean_expression'$
Parameter
Boolean_expression Any constant Boolean expression containing the
operators AND, OR, and NOT and parentheses. The SET
compiler option must assign the value TRUE or
FALSE to each identifier before it appears in
Boolean_expression. The identifier operands cannot
have the spellings of Boolean operators (NOT, AND,
OR). The operators are evaluated in the order
dictated by HP Pascal operator precedence.
Default Not applicable.
Location Anywhere.
The IF option must be used with the SET and ENDIF options, and can be
used with the ELSE option, as follows:
$SET 'identifier = Boolean [{,}identifier = Boolean]'$
[{;} ]
$IF Boolean_expression$
[source code ]
[to be compiled ]
[if Boolean_expression]
[is TRUE ]
$ELSE$
[source code ]
[to be compiled ]
[if Boolean_expression]
[is FALSE ]
$ENDIF$
IF options can be nested; that is, the source code to be compiled
conditionally can contain IF options. The maximum nesting level is 16.
Because the IF, ENDIF, ELSE, and SET options (together) allow conditional
compilation, several programmers with different needs can use them to
customize a single compilation unit.
Example 1
The following two program fragments are equivalent:
{Fragment 1}
$SET 'group1=true, group2=false'$
.
.
.
$IF 'group1 AND (NOT group2)'$
[source_line]
[ . ]
[ . ]
[ . ]
$ENDIF$
{Fragment 2}
$SET 'group1 = true'$
$SET 'group2 = false'$
.
.
.
$IF 'group1'$
$IF 'NOT group2'$
[source_line]
[ . ]
[ . ]
[ . ]
$ENDIF$
$ENDIF$
Example 2
$SET 'group1=FALSE'$
.
.
.
$IF 'group1'$
[source_line]
[ . ]
[ . ]
[ . ]
$ELSE$
[source_line]
[ . ]
[ . ]
[ . ]
$ENDIF$
Example 3
$SET 'group3=true,group2=false;group1=false'$
.
.
.
$IF 'group1'$
[source_line]
[ . ]{group1}
[ . ]
[ . ]
$ELSE$
$IF 'group2'$
[source_line]
[ . ]{group2}
[ . ]
[ . ]
$ELSE$
$IF 'group3'$
[source_line]
[ . ] {group3}
[ . ]
[ . ]
$ENDIF$
$ENDIF$
$ENDIF$
MPE/iX 5.0 Documentation