NET/MASTER Network Control Language (NCL) Programmer's Guide
Single and Repetitive Execution
Controlling Execution Flow
5–6 106160 Tandem Computers Incorporated
Using a Control Variable to Control Repetitive Execution
A DO loop that uses a control variable to execute a group of statements repetitively
can optionally use the keywords TO, BY, and FOR. The following table summarizes
the meaning of these keywords:
Keyword Meaning
TO Sets the termination value of the control variable in a repetitive DO loop.
BY Sets the value by which to increment or decrement the control variable in a repetitive DO
loop.
FOR Limits the number of repetitions of a repetitive DO loop regardless of the value of the
control variable.
The control variable you specify must be a simple variable name. This means you
cannot use complex, stem, compound, or nested variables. Nor can you use system or
global variables, or specify a variable prefix. The following examples are valid control
variables:
&abc /* Simple variable */
&loop_counter /* Simple variable */
&COUNT /* Simple variable */
The following examples are invalid control variables:
&abc. /* Stem variable */
&&abc&xyz /* Complex variable */
&abc.xyz /* Compound variable */
&abc&(xyz) /* Nested variable */
&glblabc /* Global variable */
&sys.retcode /* System variable */
&a* /* Variable prefix */
The value of the control variable must be a number or an expression that evaluates to a
number. It does not have to be an integer and it can be either positive or negative.
Using a Control Variable Without Keywords. The syntax of a DO loop that uses a control
variable without keywords is the following:
DO
cvar
=
expri
statement1
statement2
statement3
…
END
cvar
specifies the value of the control variable.