NET/MASTER Network Control Language (NCL) Reference Manual

IF
Core Statements
106126 Tandem Computers Incorporated 2–31
See also DO and SELECT. The DO core statement extends the range of possible
actions of the IF statement. The SELECT core statement provides you with an
alternative to the IF statement for multiple path processing.
Examples
The following example executes one of two statements, depending on the value of the
variable &1:
APROC: PROCEDURE
IF &1 = "YES" THEN
SAY "&1 EQUALS YES"
ELSE
SAY "&1 DOES NOT EQUAL YES AND THE STATEMENT IS FALSE."
END APROC
If the previous procedure is started from the OCS window using the parameter YES
(by entering START APROC YES), NCL displays the message &1 EQUALS YES. If the
procedure APROC is started using any other parameter, NCL displays &1 DOES NOT
EQUAL YES AND THE STATEMENT IS FALSE.
The following example shows the use of a nested IF statement to extend the possible
actions that can be taken for different values of an expression:
IF &1 = "YES" THEN
IF &2 = "NO" THEN
SAY "&1 = YES AND &2 = NO"
ELSE
NOP
ELSE
SAY "&1 NOT EQUAL TO YES"
The previous example also demonstrates the use of the NOP statement to force the
pairing of IF … ELSE blocks; in this case, you must use the NOP statement when you
want one of the conditions to result in no action.
The following example shows how to code multiple statements for the IF core
statement:
IF DATATYPE(&A,N) THEN
DO
&TOTAL = &TOTAL + &A
LAB1:
SAY "TOTAL = " &TOTAL
END
ELSE
DO
LAB2:
SAY &A " IS NOT NUMERIC"
&TOTAL = &TOTAL + &B
END