NET/MASTER Network Control Language (NCL) Reference Manual
ITERATE
Core Statements
106126 Tandem Computers Incorporated 2–33
Example
The following example is a procedure called AGAIN. This procedure adds up random
numbers supplied by the built-in function RANDOM. If the number obtained from
RANDOM is not less than 50, the procedure issues an error message and gets another
random number. When the required total is 50 or greater, the procedure displays the
total and terminates:
AGAIN: PROCEDURE
/*/
/* THIS ROUTINE ADDS UP NUMBERS
/* UNTIL THE TOTAL IS 50 OR MORE
/*/
&TOTAL = 0
LOOP1:
DO UNTIL &TOTAL >= 50
&NUMBER=RANDOM(1,100)
IF &NUMBER < 50 THEN
DO
&TOTAL = &TOTAL + &NUMBER
ITERATE LOOP1
END
SAY "NO ADDITION CARRIED OUT FOR RANDOM NUMBER" &NUMBER
END LOOP1
SAY "FINAL TOTAL IS " &TOTAL
END AGAIN
The only iterative DO group in the preceding procedure is the DO group with the label
LOOP1; you can therefore omit the label on the ITERATE core statement, if you wish.