NET/MASTER Network Control Language (NCL) Programmer's Guide

Single and Repetitive Execution
Controlling Execution Flow
106160 Tandem Computers Incorporated 5–11
Using a Control Variable With the FOR Keyword. The FOR keyword limits the number of
repetitions of a DO loop regardless of the value of the control variable. The syntax of a
DO loop that uses the FOR keyword with a control variable is the following:
DO
cvar
=
expri
[ TO
exprt
] [ BY
exprb
] FOR
exprf
statement1
statement2
statement3
END
exprf
specifies an expression that must evaluate to 0 or a positive integer. This limits the
number of repetitions regardless of the value of the control variable.
The following example shows an NCL procedure that uses a control variable with the
FOR keyword in a DO loop:
zex0507n: PROCEDURE
/* DO loop with the FOR keyword */
DO &control = 1 TO 10 BY 0.5 FOR 5
SAY &control
END
SAY "The final value of &control is "&control
END zex0507n
The initial value of the control variable, &CONTROL, is 1. The terminating value is 10;
however, the loop executes only five times because the FOR keyword specifies a value
of 5. The final value of &CONTROL is 3.5.