NET/MASTER Network Control Language (NCL) Programmer's Guide
Conditional Execution
Controlling Execution Flow
106160 Tandem Computers Incorporated 5–31
The values entered are a null value (incorrectly), 1 (January), 2 (February), 4 (April), 11
(November), 0 (incorrectly), and ABC (incorrectly).
The Second Form of the SELECT Statement
The syntax of the second form of the SELECT core statement is the following:
SELECT
expression
[ STRICT ]
WHEN
expression
THEN
statement
…
OTHERWISE
statement(s)
END
Hint To improve the performance of an NCL process, use the second form of the SELECT core statement
(because the initial expression is evaluated only once before being tested).
The second form of the SELECT core statement evaluates an initial expression and
compares it in turn against each expression following each WHEN keyword. The type
of comparison performed by this form of the SELECT statement is, by default, a test of
simple equality. If the STRICT keyword is specified, the test is a test of strict equality.
(Refer to the discussion on expressions and operators in the NonStop NET/MASTER
NCL Reference Manual for more information on tests of simple and strict equality.)
The expression following the WHEN keyword is compared to 1 (TRUE) or 0 (FALSE).
NCL executes the statement introduced by the first comparison that evaluates to TRUE
if it finds one. After execution, control passes to the END keyword, which closes the
block of statements introduced by the SELECT keyword.
The OTHERWISE keyword is optional. If NCL does not find an expression that
evaluates to TRUE, NCL executes the statement(s) introduced by the OTHERWISE
keyword if the OTHERWISE keyword is present. If the OTHERWISE keyword is not
present, NCL raises an error.
Performing a Test of Simple Equality Using SELECT. The following example shows an NCL
procedure that uses the second form of the SELECT statement:
zex0521n: PROCEDURE
/* Second form of SELECT */
SELECT &1
WHEN A THEN SAY "First parameter = a"
WHEN B THEN SAY "First parameter = b"
OTHERWISE
SAY "First parameter is neither a nor b"
END
END zex0521n
This procedure uses the SELECT statement to evaluate the parameter entered when
the procedure is executed. The procedure performs a test of simple equality.