#DEFINE

Directive

Syntax

Adds a symbol for #IF with #DEFINE, or removes one with #UNDEF. A symbol has no value: it is defined or not.

#DEFINE <symbol>
#UNDEF <symbol>

Also written : #UNDEF

Parts

<symbol>One name: letters, digits and _, not starting with a digit. Case is ignored.

Good to know

  • It applies from its line on, for the rest of the program, files included after it too. A module of #DEFINEs included first acts as a settings file.
  • No value and no macros: #DEFINE LEVEL 3 is refused with #DEFINE requires one symbol. For a named value, use #CONSTANT.
  • A #DEFINE or #UNDEF inside a dropped #IF branch does nothing.
  • #UNDEF also removes a profile symbol: after #UNDEF DEBUG, #IFDEF DEBUG is false even in the editor.
  • A symbol cannot be read by the running program. It exists only for #IF, #IFDEF and #IFNDEF.

Example

#DEFINE CHEATS#IF CHEATS AND NOT RELEASEConsole("cheat keys on")   ' cheat keys on#ENDIF#UNDEF CHEATS#IFDEF CHEATSConsole("never printed")#ENDIF
In the manual : The preprocessor