Skip to main content

#ifNDef

Marks the beginning of a block of conditional code where execution depends on a macro having not been defined.

Description

This macro preprocessor directive marks the beginning of a block of conditional code where execution depends on a macro having not been defined. It has the form:

#ifNDef 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 not been defined. Execution continues until reaching a #else directive or a closing #endif directive. The #elseIf directive is not for use with #ifNDef.

Note:

#ifNDef has an alternate name of #ifUnDef. The two names behave identically.

For example, the following provides a simple binary switch based on a macro not having been defined:

#define Multicolor 256
 
#ifNDef Multicolor
  SET NumberOfColors = 2
#else
  SET NumberOfColors = $$$Multicolor
#endif
  WRITE "There are ",NumberOfColors," colors in use.",!
FeedbackOpens in a new tab