NET/MASTER Network Control Language (NCL) Reference Manual

PROCEDURE
Core Statements
106126 Tandem Computers Incorporated 2–47
See also CALL and RETURN. The CALL core statement allows you to specify
certain options that affect the sharing of variables with a procedure. The RETURN
core statement provides you with a method of augmenting any list of shared
variables on returning from a procedure.
For further information on the use of the FOLD and NOFOLD operands, and the
SIMPLE and SMART operands, refer to the NonStop NET/MASTER NCL
Programmer's Guide.
Examples
In the following example, a procedure named PROC1 calls another procedure named
PROC2 and passes the parameter “abcdef” in lowercase:
PROC1: PROCEDURE
CALL PROC2 (abcdef)
EXIT
PROC2: PROCEDURE FOLD
&X = &1
SAY "THIS IS &X " &X "AND THIS IS &1" &1
SAY "THE CURRENT PROCEDURE NAME IS " &SYS.NCL.CURRPROC
SAY "THE BASE PROCEDURE NAME IS " &SYS.NCL.BASEPROC
EXIT
END PROC2
END PROC1
In the preceding example, the display of both variables &x and &1 shows the string
“abcdef” folded to uppercase. If you remove the FOLD operand from PROC2, the
string is left in lowercase, which is the default for calling procedures. To display the
names of the called and calling procedures, two further SAY statements are coded
within PROC2.
The following example shows how specifying the SHARE operand in a procedure call
affects the sharing of variables:
PROC2: PROCEDURE
/* Sharing through a procedure call */
&VAR_3 = 1
CALL CONTROL_PROC SHARE &VAR_3
CONTROL_PROC: PROCEDURE
&VAR_3 = 2
END CONTROL_PROC
SAY "Value for &var_3 is" &var_3
END PROC2
In the preceding example, the second call to CONTROL_PROC shares the variable
&var_3. Its value is changed from 1 to 2.