NET/MASTER Network Control Language (NCL) Reference Manual
FUNCTION
Core Statements
106126 Tandem Computers Incorporated 2–19
FUNCTION The FUNCTION core statement declares a user-written function. A function performs
a task and returns a single result. The result of a function effectively replaces the
expression (function reference) that called the function. NCL distinguishes between
three different types of functions: external functions, internal functions, and built-in
functions.
If the FUNCTION core statement is the first statement in a source file, it is an external
function that can be referred to by other NCL procedures. If the FUNCTION core
statement occurs within an NCL procedure, or is not the first statement in a file, it is an
internal function and can only be referred to by expressions within the same source
file.
Built-in functions are NCL system-supplied functions that provide many commonly
required values, such as date and time. See Section 4, “Built-in Functions,” for a
description of all NCL built-in functions.
An attempt to call a function by using the CALL statement results in a run-time error.
Functions must return a single value with the RETURN statement. You cannot return
any variables from a function, although the SHARE operand can result in variables
being logically returned. The EXIT statement is not permitted within a function.
It is good practice to define all internal functions in a block of code separated from the
rest of the procedure. However, the function statements must not appear after the
END statement of a procedure. If you code a FUNCTION core statement within other
executable code, NCL ignores it and moves on to the next executable statement.
A function definition must be in code that is not nested in a DO group. This means
that you cannot define a function within DO, IF … ELSE, or SELECT statements.
Function definitions can be nested. Internal definitions can have the same name as the
parent definition, if you wish. However, external references (from other NCL
procedures) to the function name refer only to the parent definition.
label
: FUNCTION [ { SHARE | NOSHARE } {
share-list
| NO } ]
statement
…
END [
label
]
share-list
=
element
[,
element
] …
element
:
&*
&
simple-variable
[ * ]
&
stem-variable
. [ * ]
CALLER