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

Sharing Variables to Procedures and Functions
Procedures and Functions
106160 Tandem Computers Incorporated 6–31
When the CONTROL_PROC1 procedure is called from the top-level procedure, the
default setting of CONTROL NOSHRVARS is in effect: the value of &VAR_1 does not
change. When the CONTROL_PROC2 procedure is first called, CONTROL
NOSHRVARS is in effect: again, the value of &VAR_1 does not change. However, the
setting of CONTROL SHRVARS explicitly enables variable sharing for &VAR_1 before
CONTROL_PROC2 is called again: this time the value of &VAR_1 is changed.
Sharing Through a Procedure Call
When an NCL procedure calls another NCL procedure with the CALL core statement,
it can specify whether to share variables using either the SHARE or NOSHARE
keyword.
Note You cannot control variable sharing on a function call. You must do so before the function call by using
either the CONTROL verb or through the function declaration.
The following example shows how specifying the SHARE keyword on a procedure
call affects variable sharing:
zex0616n: PROCEDURE
/* Sharing through a PROCEDURE call */
&var_1 = One
SAY "Pre-procedure call var_1 is "&var_1
CALL control_proc
SAY "Post-procedure call var_1 is "&var_1
CALL control_proc SHARE &var_1
SAY "Post-procedure call (SHARE), var_1 is "&var_1
control_proc: PROCEDURE
&var_1 = Two
END control_proc
END zex0616n