Language Reference Guide : Preprocessing Your 4GL Code : Preprocessor : The #if - #endif Statement
 
Share this page          
The #if - #endif Statement
The #if statement can be used to conditionally include or exclude lines of source code at compile time and to test if a condition is TRUE. It has the following syntax:
# if (bool_expr) [then]
      ...
# else
      ...
# endif
bool_expr
Specifies an integer or character expression that evaluates to TRUE (1) or FALSE(0).
If the expression is TRUE, then any code between the #if and #else is processed and any code between the #else and #endif is ignored. If the tested condition is FALSE, then any lines between the test and an #else, or the test and the #endif (if the #else is omitted) are ignored. The preprocessor removes all of the following statements from the file that are passed to the compiler:
#if 0
/* shared procedures */
#include nameproc
#endif
Guidelines for Using the #if – #endif Statement
The following syntax rules apply to the #if statement:
Arguments are not permitted in #if statements.
The statement:
# if $variable then ...
is equivalent to:
# if($variable<>0)then ...
The #if statement can be nested within other #if, #ifdef, and #ifndef statements up to a depth of 20.