Compiler conditional statements
Selected portions of PL/MX source can be conditionally compiled by using compiler conditional statements and the
PLMX_CCFLAGS
command-line argument.
Syntax
$IF conditional-boolean-expression $THEN
source
[$ELSIF conditional-boolean-expression $THEN source]
[$ELSE source]
$END
conditional-boolean-expression :=
[(] [unary-boolean-operator] conditional-boolean-operand
[ binary-boolean-operator conditional-boolean-expression ] [)]
conditional-boolean-operand :=
$$ccflags-variable
| FALSE
| TRUE
| NULL
| conditional-boolean-expression
| conditional-comparison-expression
unary-boolean--operator := NOT
binary-boolean-operator :=
AND
| OR
conditional-comparison-expression :=
conditional-arithmetic-expression relational-operator
conditional-arithmetic-expression
| conditional-boolean-expression relational-operator
conditional-boolean-expression
relational-operator :=
=
| <
| <=
| >
| >=
| ^=
| !=
| <>
| ~=
Examples
Where,
source
-
PL/MX source such as statements, comments, or additional compiler conditional statements.
conditional-boolean-expression
-
It is a Boolean expression as described in the syntax.
ccflags-variable
-
Is the name of a variable defined in the
-plmx_ccflags
command-line option. For more information on theplmx_ccflags
option, see The Standalone Compiler. conditional-arithmetic-expression
-
A numeric literal in the range
-2147483647
through2147483647
.
A simple $IF statement using the literal constant TRUE.
$IF TRUE $THEN
--- Include this source in the compilation.
$END
A $IF statement with $ELSIF and $ELSE.
$IF $$compileThis $THEN
--- Include this source in the compilation.
built_for_flag := 1;
$ELSIF $$compileThat $THEN
--- Include that source in the compilation.
built_for_flag := 2;
$ELSE
--- Include from here when it’s neither this nor that.
built_for_flag := 3;
$END