NET/MASTER Network Control Language (NCL) Programmer's Guide
Conditional Execution
Controlling Execution Flow
5–34 106160 Tandem Computers Incorporated
The following example shows an NCL that uses the SELECT statement with the DO
statement:
zex0523n: PROCEDURE
/* SELECT statement with the DO statement */
&size = 0
SAY "Enter size of rectangle (3-15)"
CMDLINE "-GO ID="&SYS.NCLID _
PAUSE VARS=&size
SELECT
WHEN NOT(DATATYPE(&size,W)) THEN DO
SAY &size" is rubbish"
CALL zex0523n
END
WHEN &size < 3 THEN DO
SAY &size" is too small"
CALL zex0523n
END
WHEN &size > 15 THEN DO
SAY &size" is too big"
CALL zex0523n
END
OTHERWISE
SAY &size" is valid"
DO &size
SAY COPIES("*",(2 * &size))
END /* do */
END /* select */
END zex0523n
This procedure obtains input from the OCS command input line to draw a rectangle.
It uses a SELECT statement to check the input and take action. If the input is invalid,
the procedure displays a message and reexecutes itself. The procedure uses the DO
statement in two ways: the DO statement after the THEN keyword groups statements
together; and the DO statement after the OTHERWISE keyword executes a statement
repetitively.