TAL Reference Manual
Compiler Directives
TAL Reference Manual—526371-001
16-48
Usage Considerations
Usage Considerations
IF, IFNOT, and ENDIF can appear in a directive line anywhere in the source code but
not in the compilation command. IF and IFNOT must appear last in any directive line.
ENDIF must be the only directive on the directive line.
For ENDIF, always specify a toggle that matches a previous IF or IFNOT toggle.
ENDIF terminates the compilation begun by the IF or IFNOT that specifies the
matching toggle.
Named or Numeric Toggles
For named or numeric toggles, IF causes compilation of subsequent text only if you
turn the same toggle on with SETTOG.
IFNOT causes compilation of subsequent text only if the same toggle is turned off. A
toggle is turned off if you create it with DEFINETOG or RESETTOG, or if you create it
with SETTOG and then turn it off with RESETTOG.
For both IF and IFNOT, the skipping of text, once begun, continues until the matching
ENDIF directive appears. In the following fragment, the compiler skips both parts if the
toggle is off, because no ENDIF appears for IF. Avoid this error:
? RESETTOG flag !Create FLAG in off state
?IF flag
!Statements for true condition
! (skipped because FLAG is off)
?IFNOT flag
!Statements for false condition
! (also skipped because no ENDIF appears for IF FLAG)
?ENDIF flag
If you insert an ENDIF for IF in the preceding fragment, the compiler skips only the first
part:
? RESETTOG flag !Create FLAG in off state
?IF flag
!Statements for true condition
! (skipped because FLAG is off)
?ENDIF flag !ENDIF stops the skipping of statements
?IFNOT flag
!Statements for false condition
! (compiled because ENDIF appears for IF FLAG)
?ENDIF flag