Conditional Compilation
You can specify the conditions under which all or part of a BASIC program is to be compiled, using:
- A modified version of the IF statement
- $IFDEF statement
- $IFNDEF statement
Conditional compilation with the modified IF statement is useful for customizing large programs that are to be used by more than one kind of user. It can also reduce the size of the object code and increase program efficiency.
You can use the compiler directives $IFDEF and $IFNDEF to control whether or not sections of a program are compiled. Both of these compiler directives test a given identifier to see if it is currently defined (that is, has appeared in a $DEFINE statement compiler directive and has not been undefined). If the identifier that appears in a $IFDEF is defined, all the program source lines appearing between the $IFDEF compiler directive and the closing $ENDIF compiler directive are compiled. If the identifier is not defined, all the lines between the $IFDEF compiler directive and the $ENDIF compiler directive are ignored.
The $IFNDEF compiler directive is the complement to the $IFDEF compiler directive. The lines following the $IFNDEF compiler directive are included in the compilation if the identifier is not defined. If the identifier is defined, all lines between the $IFNDEF compiler directive and the $ENDIF compiler directive are ignored. $IFDEF and $IFNDEF compiler directives can be nested up to 10 deep.