The IFDEF and IFNDEF keywords are used to perform conditional compilation. The parameter of both statements is a string, which represents a preprocessor variable. Based on the status of the given variable (whether it is defined or not), the compiler either includes or excludes the block of code that follows. For example:

IFDEF "myVariable" {
	PRINT VALUE "myVariable"
}

If, during compilation, the preprocessor variable "myVariable" is defined, the resulting program will include the code that will print its value. If the variable is not defined, then the entire IFDEF statement, along with the code block, will be ignored, and will not be included in the resulting program.

The IFNDEF statement checks for the opposite condition. For example:

IFNDEF "myVariable" {
	PRINT "Not defined"
}
ELSE {
	PRINT VALUE "myVariable"
}

As shown above, also the ELSE keyword is allowed.

Note that unlike the if statements, these are preprocessor statements: The comparisons are executed during compilation, not while the program is running.


Twitter Facebook LinkedIn Youtube Slideshare Github