NET/MASTER Network Control Language (NCL) Programmer's Guide
Sharing Variables to Procedures and Functions
Procedures and Functions
6–24 106160 Tandem Computers Incorporated
Sharing Variables to
Procedures and
Functions
Every procedure and function called during the execution of an NCL process creates
its own set of variables. These variables are local to the procedure or function and are
deleted when the procedure or function terminates. Although the variables in one
procedure or function are local to that procedure or function, you can temporarily
share them with other procedures or functions.
To share variables means to pass the names and current values of variables from one
procedure or function (the caller) to another procedure or function (the callee). A
caller procedure or function passes one or more variables; the callee procedure or
function receives the variables. The callee can then work with the variables. It can
change the values of the variables or delete the variables. When the callee terminates,
it gives the variables back to the caller with the current values (unless deleted).
NCL does not share variables by default; you must explicitly enable or disable variable
sharing. To do so, follow these steps:
1. Specify the method of variable sharing or not sharing in both the caller and callee.
This is described in “Methods of Variable Sharing” later in this section.
2. Specify the variables to share or not to share in a share list in both the caller and
callee. This is described in “The Contents of a Share List” later in this section.
3. Ensure that the net interaction between the variable sharing methods and the
share lists in both the caller and callee allows the appropriate variables to be
shared or not shared. This is described in “Interaction Between Variable Sharing
Methods” later in this section.
Methods of Variable
Sharing
There are three ways to specify the method of variable sharing from one procedure or
function to another procedure or function:
With the CONTROL verb
Through a procedure or function declaration
Through a procedure call
Note The RETURN core statement is also used to pass variables from a callee procedure to a caller procedure.
This is described earlier in this section.
Sharing With the CONTROL Verb
The CONTROL verb has two keywords that control whether a procedure or function
can share variables: SHRVARS and NOSHRVARS. The default setting is CONTROL
NOSHRVARS; this prohibits variable sharing between one procedure or function and
another procedure or function.