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

Terminating Execution of the Current Procedure or Function
Procedures and Functions
106160 Tandem Computers Incorporated 6–13
Terminating Execution
of the Current
Procedure or Function
The procedure or function that is executing within an NCL process is the current
procedure or function. This subsection explains how to terminate the execution of the
current procedure or function by using the following core statements:
END
EXIT
RETURN
The following table summarizes when you can use the END, EXIT, and RETURN
statements to terminate the execution of the current procedure or function:
Statement Procedure Function
END Must be used to terminate a procedure
declaration. Can be used to terminate
execution of a procedure; if so, does
not return a return code.
Must be used to terminate a function
declaration. Cannot be used to
terminate execution of a function.
EXIT Can be used to terminate execution of
a procedure; if so, can return a return
code.
Cannot be used in a function.
RETURN Can be used to terminate execution of
a procedure; if so, must specify a list
of variables (without parentheses) to
pass to the calling procedure or
function.
Must be used to terminate execution of
a function to return the result of the
function; the result must be an
expression in parentheses.
This subsection does not discuss how to terminate the execution of an NCL process.
This is covered in Section 8, “Executing NCL Procedures.”
The END Statement—
Procedures Only
The END core statement closes a block of statements beginning with either the DO,
FUNCTION, PROCEDURE, or SELECT core statement. It is used to terminate a
procedure and function declaration.
You can follow the END statement by the label (or any one of the labels if more than
one) that precedes the initial FUNCTION or PROCEDURE statement. During
compilation, this allows the compiler to check that a procedure or function is correctly
nested.
You can use END to terminate the execution of a procedure. However, you cannot use
END to terminate the execution of a function (you must use the RETURN core
statement to terminate the execution of a function.) If NCL encounters END in a
function, it raises an error.
Note You cannot recover from the error if NCL encounters the END core statement in a function because the
END statement is the last statement in the function.
In a procedure, if NCL encounters END before an EXIT core statement, it treats END
as an implicit EXIT. You cannot use END to set a return code in the system variable
&SYS.RETCODE. Encountering END before EXIT does not affect the value of
&SYS.RETCODE.