NET/MASTER Network Control Language (NCL) Programmer's Guide
Conditional Execution
Controlling Execution Flow
106160 Tandem Computers Incorporated 5–25
Conditional Execution There are three core statements that control the conditional execution of a statement or
a group of statements:
IF
SELECT
NOP
The IF Statement The IF core statement tests an expression. It allows NCL to make a two-way decision
based on the outcome of the test. The options are introduced by the THEN and ELSE
keywords. The syntax of the IF statement is the following:
IF
expression
THEN
true-statement
ELSE
false-statement
The expression following the IF statement must evaluate to 1 (TRUE) or 0 (FALSE). If
the expression evaluates to TRUE, NCL executes the statement introduced by the
THEN keyword. It skips any statement introduced by the ELSE keyword. If the
expression evaluates to FALSE, NCL skips the statement introduced by the THEN
keyword. The ELSE keyword is optional. If the ELSE keyword is present, NCL
executes the statement introduced by ELSE.
Hint To improve the performance of an NCL process, when testing multiple expressions, use a single IF
statement with Boolean operators (AND, OR, XOR, and NOT) rather than multiple IF statements.
The following example shows an NCL procedure that uses the IF core statement:
zex0517n: PROCEDURE
/* IF statement */
&answer = SUBSTR(UPPER(&1),1,1)
IF &answer = Y THEN
SAY The answer is YES
ELSE
SAY The answer is NO
END zex0517n
This procedure tests the value of the parameter entered when the procedure is
executed. If the first letter of the parameter is Y, the IF statement evaluates to TRUE
and the statement following THEN is executed. If the first letter of the parameter is
not Y, the IF statement evaluates to FALSE and the statement following ELSE is
executed.