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

Passing Parameters to Procedures and Functions
Procedures and Functions
6–18 106160 Tandem Computers Incorporated
Passing Parameters to
Procedures and
Functions
A parameter is a value passed to a procedure or function when the procedure or
function is called. This subsection discusses how to use parameter variables, how to
use the system variables &SYS.PARMCNT and &SYS.ALLPARMS, and how to specify
parameter handling in a procedure declaration.
Parameter Variables When a parameter is passed to a procedure or function it is placed in a special type of
variable called a parameter variable. A parameter variable is a user variable from &1
through &n, where n is the number of the last parameter variable created and is a
positive integer. Parameter variables are automatically created by NCL when a
procedure or function is called (if parameters are passed).
Parameters are positional. &1 is the first parameter variable created to hold the first
parameter passed to an NCL procedure or function, &2 is the second, &3 is the third,
and so on. This means that parameters must be passed to an NCL procedure or
function in the order that the procedure or function expects to receive them.
The following example shows a top-level procedure that passes parameters to a
lower-level procedure, which passes the parameters back to the top-level procedure:
zex0610n: PROCEDURE NOFOLD EXTPARSE SMART
/* Passing parameters */
SAY Top level
SAY "&1 is "&1; SAY "&2 is "&2
SAY "Value of &SYS.PARMCNT is "&SYS.PARMCNT
SAY "Value of &SYS.ALLPARMS is "&SYS.ALLPARMS
CALL first_level (One, Two, Three)
first_level: PROCEDURE
SAY First level
SAY "&1 is "&1; SAY "&2 is "&2; SAY "&3 is "&3
SAY "Value of &SYS.PARMCNT is "&SYS.PARMCNT
SAY "Value of &SYS.ALLPARMS is "&SYS.ALLPARMS
&1 = Gold; &2 = Silver
RETURN &1, &2, &3
END first_level
SAY Top level
SAY "&1 is "&1; SAY "&2 is "&2; SAY "&3 is "&3
SAY "Value of &SYS.PARMCNT is "&SYS.PARMCNT
SAY "Value of &SYS.ALLPARMS is "&SYS.ALLPARMS
END zex0610n
This procedure shows how parameters can change values.