Introduction MTB Statements File System Compiler Applications Reference Guide Index

Overview Creating MTB Source Programs Compiling MTB Programs Compiler Directives Special Characters

.IF directive

Syntax: .IF symbolic-constant
Discussion: The .IF statement is a compiler directive. As such, it causes an action to occur when the program is compiled, not when the program is executed. The .IF directive can appear anywhere in an MTB source program.

Within an MTB source program, specific lines can be identified as conditional source segments. A conditional source segment begins with the .IF directive (or one of its alternatives) and ends with the .ENDIF directive, as follows:

.IF symbolic-constant

(conditional source segment)

.ENDIF

The MTB compiler will compile the conditional source segment only if the symbolic constant has been SET to a non-zero value.

See Conditional Compilation.

Example: In the following example, the symbolic constant named ABC is set to a non-zero value. When the compiler reaches the .IF directive, it compiles the subsequent lines up through the .ENDIF directive. Note, however, that if ABC was either not defined (not SET) or contained a value of 0, the compiler would skip the conditional source segment.

  SET ABC = 1       ! set the symbolic constant to a non-zero value

  .IF ABC           ! beginning of conditional source segment

   MTB code segment

  .ENDIF            ! end of conditional source segment