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

Single and Repetitive Execution
Controlling Execution Flow
106160 Tandem Computers Incorporated 5–23
The LEAVE Core Statement
The LEAVE core statement immediately exits a DO loop. The LEAVE statement
logically passes control to the statement immediately after the bottom (the END
statement) of a DO loop. (It logically meets the condition that terminates the DO
loop.)
If you do not specify a target label after the LEAVE statement, LEAVE passes control
to the statement following the END statement at the bottom of the DO loop in which
the LEAVE statement is executed. If you do specify a target label, the LEAVE
statement searches for the label. If you specify a label after the LEAVE statement, it
must be constant.
The following example shows an NCL procedure that uses the LEAVE core statement
to exit a DO loop:
zex0516n: PROCEDURE
/* Adds up numbers until user enters a "non-number" */
&total = 0
DO FOREVER
SAY "Enter a number in the OCS command input line"
CMDLINE "-GO ID="&SYS.NCLID _
PAUSE VARS=&number
SAY "You have entered "&number
IF NOT(DATATYPE(&number,N)) THEN
LEAVE
&total = &total + &number
END
SAY "Final total is "&total
END zex0516n
This procedure adds numbers that a user enters in the OCS command input line.
When the user enters a value that is not a number, the LEAVE statement is executed,
the DO loop terminates, the total is displayed, and the NCL process terminates
execution.