Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The #if compiler directive is used to test a condition expression for conditional compilation.

If the conditional expression is true, source lines following the #if directive are selected to be read by the compiler. Otherwise, lines are excluded until the next #elseif, #else, or #endif in the same #if group are reached.

The syntax is as follows:

Code Block
#if defined(condition)

or

Code Block
#if not defined(condition)


Example:

Code Block
languagejavascript
#if not defined(ranonce)
  // this code will only run one time 
  // even if this source file is included more than once in a program, using pjs.include()
  number = number + 1;
#endif
#define ranonce


RPG Equivalent:

/IF