#ifDef
Description
This macro preprocessor directive marks the beginning of a block of conditional code where execution depends on a macro having been defined. It has the form:
#ifDef macro-name
where macro-name appears without any leading $$$ characters. Anything following macro-name on the same line is considered a comment and is not parsed.
Execution of the code is contingent on the macro having been defined. Execution continues until reaching a #else directive or a closing #endif directive.
#ifDef checks only if a macro has been defined, not what its value is. Hence, if a macro exists and has a value of 0 (zero), #ifDef still executes the conditional code (since the macro does exist).
Also, since #ifDef checks only the existence of a macro, there is only one alternate case (if the macro is not defined), which the #else directive handles. The #elseIf directive is not for use with #ifDef.
For example, the following provides a simple binary switch based on a macro’s existence:
#define Heads
#ifDef Heads
WRITE "The coin landed heads up.",!
#else
WRITE "The coin landed tails up.",!
#endif