NET/MASTER Network Control Language (NCL) Reference Manual
DO
Core Statements
2–14 106126 Tandem Computers Incorporated
See GOSUB, GOTO, ITERATE, and LEAVE. The GOSUB and GOTO core
statements have some restrictions in transferring to labels within DO groups. The
ITERATE and LEAVE core statements can pass control out of a DO group.
Examples
The following example is a simple iterative DO group. The code increments the value
of the variable &I from 1 to 10 and displays each value:
DO &I = 1 TO 10
SAY I IS &I
END
The following example loops ten (exprt) times, unless the variable &B5 (exprf) is
less than ten, when it loops exprf times:
DO &I = 1 TO 10 FOR &B5
SAY "&I = " &I
END
The following example of a noniterative DO core statement illustrates how multiple
statements can be grouped under an IF statement:
IF expr THEN DO
SAY "IT’S TRUE"
SAY "REALLY!!!"
END
The following example shows a DO group using the WHILE keyword. The procedure
executes a DO group while the value of the variable &NUMBER is less than or equal to
10. The procedure displays the numbers 1 through 10. The final value, displayed after
the DO group terminates, is 11:
WHILE_PROC: PROCEDURE
/* do group using the WHILE keyword */
&NUMBER = 1
DO WHILE &NUMBER <= 10
SAY &NUMBER
&NUMBER = &NUMBER + 1
END
SAY "THE FINAL VALUE OF &NUMBER IS "&NUMBER
END WHILE_PROC