NET/MASTER Network Control Language (NCL) Reference Manual

&SYS.LOOPCTL
System Variables
5–54 106126 Tandem Computers Incorporated
&SYS.LOOPCTL The &SYS.LOOPCTL system variable contains the current setting of the automatic
loop control counter. It is used to control the number of times a loop is performed
within a DO group, and also the number of times GOSUB and GOTO statements are
executed.
The system default value for &SYS.LOOPCTL is 1000. This value decrements by one
each time a loop is executed or each time a GOSUB or GOTO statement is executed.
When an NCL procedure exits from a loop, the counter is not automatically reset to the
default value. If the counter reaches 0 (zero), the NCL process is terminated on the
assumption that it is looping uncontrollably, or that repeated executions of GOSUB or
GOTO statements are out of control. NCL sets this system variable to 1000 each time
CNMREAD, EMSREAD, INTREAD, LOGREAD, or MSGREAD is executed, unless the
user explicitly sets it to 0 (zero).
&SYS.LOOPCTL
Considerations
The maximum value to which this variable can be set is 10000.
An assignment statement can be used to alter the default value of this variable.
This should be done if you expect the number of times the execution of a valid
loop, or the number of executions of GOSUB or GOTO statements, to exceed the
default value during standard NCL processing. See the assignment core statement
in Section 2, “Core Statements.”
You can remove any checking of &SYS.LOOPCTL by NCL if you set the initial
value to zero.
If your NCL procedure performs lengthy iterations, you can check the
decrementing value of &SYS.LOOPCTL and avoid abnormal termination of the
procedure because of uncontrolled looping.
Example
In the following example, &SYS.LOOPCTL limits the DO group to repeating only five
times, even though the formal request was to repeat the DO group ten times:
APROC: PROCEDURE
&SYS.LOOPCTL = 5
DO &I = 1 TO 10
SAY "&I = " &I
END
END APROC