
Chapter 4 293
Command Definition F-K
IF
Operation Notes
This command begins an IF block consisting of all the commands after the IF command up
to, but not including, the next ELSE. ELSEIF, or ENDIF statement. The ELSE, ELSEIF,
or ENDIF must have the same nesting level as the IF statement. Another similar block
can follow the ELSE statement.
Nesting of the blocks is allowed to 30 levels so long as IF is used alone. In a case where IF
is used with WHILE the total nesting of IF and WHILE blocks cannot exceed 30 levels.
Each IF or WHILE block read by the Command Interpreter increments the nesting count
even if it resides within a different UDC or COMMAND file.
The ENDIF statement ends the IF block. The logical expression is evaluated and, if the
expression evaluates to TRUE, the IF block is executed; if FALSE, the ELSE or ELSEIF
block (if one exists) is executed.
NOTE You may not write an IF construct in such a way that it physically crosses
from one user command (UDCs or command files) to another.
Use
This command may be issued from a job, session, program, or in BREAK. Pressing Break
has no effect unless expression contains the INPUT evaluator function.
Example
The following job listing illustrates the use of an IF statement with ELSE and ENDIF
statements:
!CONTINUE
!PASXL MYPROG,MYUSL
!IF JCW>=FATAL THEN
! TELL USER.TECHPUBS;COMPILE FAILED
!ELSE
! TELL USER.TECHPUBS;COMPILE COMPLETED
!ENDIF
Related Information
Commands CALC, ELSE, ELSEIF, ENDIF, WHILE, ENDWHILE, ESCAPE, RETURN
Manuals Appendix B, "Expression Evaluator Functions"