NET/MASTER Network Control Language (NCL) Reference Manual

FUNCTION
Core Statements
2–22 106126 Tandem Computers Incorporated
Considerations
Functions save the caller's DO, GOSUB, and ON statuses. Any error conditions
triggered by a function determine the current ON block for that condition. ON
blocks can be defined within a function. (The ON core statement, described later
in this section, defines an ON block.)
For a full discussion of the sharing of variables between NCL procedures and
functions, refer to the NonStop NET/MASTER NCL Programmer's Guide.
See also the CONTROL verb in Section 3, “Verbs.” The SHRVARS/NOSHRVARS
operands of this verb can affect the performance of the FUNCTION core
statement.
See RETURN, described later in this section, which shows how to return the value
that a function generates.
Examples
The following example shows a simple function definition that displays the
mathematical cube of a number:
APROC: PROCEDURE
SAY " THE CUBE OF " &1 " IS " CUBE(&1)
CUBE: FUNCTION
&RESULT=(&1**3)
RETURN (&RESULT)
END CUBE
END APROC
The RETURN core statement, in the previous example, is a mandatory statement that
returns the function’s value to the user. The parentheses are necessary.