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

Single and Repetitive Execution
Controlling Execution Flow
5–22 106160 Tandem Computers Incorporated
The following example shows an NCL procedure that uses the ITERATE core
statement to iterate a DO loop:
zex0515n: PROCEDURE
/* Adds up numbers until total is greater than */
/* or equal to 50 */
&total = 0
DO UNTIL &total >= 50
SAY "Enter a number in the OCS command input line"
CMDLINE "-GO ID="&SYS.NCLID _
PAUSE VARS=&number
SAY "You have entered "&number
IF DATATYPE(&number,N) THEN DO
&total = &total + &number
ITERATE
END
SAY &number" is not a number"
END
SAY "Final total is "&total
END zex0515n
This procedure adds numbers that a user enters in the OCS command input line.
When the user enters a value, it is checked. If it is a number, it is added to a
progressive total and the ITERATE statement passes control to the bottom of the loop
where the UNTIL condition is tested. If the total is more than 50, the NCL process
terminates. If the user enters a value that is not a number, the DO loop is repeated.
The following screen shows the results of executing the procedure:
(08:15) --------------------- OPERATOR CONTROL SERVICES ----------------------
START ZEX0515N
Enter a number in the OCS command input line
|NM1060 PROCEDURE ZEX0515N NCLID 57 PAUSED
You have entered 16
Enter a number in the OCS command input line
|NM1060 PROCEDURE ZEX0515N NCLID 57 PAUSED
You have entered 14
Enter a number in the OCS command input line
|NM1060 PROCEDURE ZEX0515N NCLID 57 PAUSED
You have entered ABC
ABC is not a number
Enter a number in the OCS command input line
|NM1060 PROCEDURE ZEX0515N NCLID 57 PAUSED
You have entered 42
Final total is 72
NNM1005 START ZEX0515N PROCESSING COMPLETE. NCLID 000057
_____________________________________________________________________________
---------- ------------------ NonStop NET/MASTER D30 ---------------- --------
M=>
The values entered are 16, 14, ABC (incorrectly), and 42. After 42 is entered, the total is
72, and the NCL process terminates execution.