Previous Topic: &CALL

Next Topic: &CALL program


&CALL procedure

This format invokes an NCL procedure to nest to another procedure.

&CALL PROC=procname
    [ SHARE | SHARE=(sharvars1,sharvars2,...,shrvarsn) |
      NOSHARE=(sharvars1,sharvars2,...,shrvarsn) ]
    [ PARMS=(parm1, parm2,...,parmn) ] }

When using &CALL to nest to another NCL procedure, the resulting call path is equivalent to the result from an EXEC command. However, the ability to pass parameters and variables across the call boundary is more structured using the &CALL verb than the EXEC command.

Operands:

PROC=procname

Specifies a nested NCL procedure call to the procedure procname. The &CALL verb does not complete until the called procedure ends.

SHARE | SHARE=(shrvars1,shrvars2,...,shrvarsn) | NOSHARE=(shrvars1,shrvars2,...,shrvarsn)

Specifies the set of NCL variables and/or MDOs, to be shared or not shared, with the called procedure.

If the SHARE or NOSHARE keywords are omitted, no variable sharing occurs for this call. If the SHARE keyword is coded without parameters, the current &CONTROL SHRVARS (or NOSHRVARS) setting is used for the call.

If the SHARE or NOSHARE keyword is used with parameters, any current &CONTROL SHRVARS settings are ignored for this execution. When SHARE is used, the called procedure obtains a copy of each variable and/or MDO referenced by the SHARE operand. When NOSHARE is used, the called procedure obtains a copy of all NCL variables and MDO data not specified by the operand.

Note: The parameter values for SHARE and NOSHARE cannot be substituted on the statement.

The operand can specify a single value or a list of values. Each item in the list can reference a single variable or MDO, or multiple variables or MDOs. A single variable is referenced by including its entire name. For example, an entry in the list of 'ABC' refers to the single NCL variable &ABC, as though VARS=ABC were coded. A single MDO is referenced by including its entire name followed by a full stop. For example, an entry in the list of 'ABC.' refers to the single MDO named ABC, as though MDO=ABC were coded.

A range of NCL variables is referenced by including a name prefix followed by an asterisk. For example, an entry in the list of '$CNM*' refers to $CNM1...$CNMnnn. The range is set explicitly. For example, '$CNM*(1,10)' (or '$CNM(1,10)') refers to the variables $CNM1 to $CNM10. If not set explicitly, all variables are assumed to be of the form $CNMnnn.

A generic list of NCL variables and MDOs is referenced by including a name prefix followed by a > symbol. For example, an entry in the list of '$NW>' refers to all variables, and MDOs, with names beginning with &$NW.

PARMS=(parm1,parm2,...,parmn)

Specifies a list of parameters to pass to the procedure. You enclose the parameter list by parentheses and separate each parameter by a comma.

The parameter list can contain any combination of characters, including variables. The first parameter isolated is placed in &1 in the target procedure, the next in &2, and so on.

The list is analyzed before substitution occurs, and each parameter is isolated by scanning for a comma or the closing parenthesis. If another opening parenthesis is encountered, a syntax error results.

If a single or double quote is encountered as the first character of a parameter, the entire parameter is assumed to be quoted, otherwise it is treated as unquoted.

If an unquoted parameter is encountered, the next comma or closing parenthesis delimits it. Any other characters are considered part of the parameter itself (including embedded blanks).

When a parameter does not start with a quote, but contains quotes, normal quoting rules apply and the data is substituted. In the following example, &1 is PARM1='ABC' and &2 is PARM2=XY Z for MYPROC:

&VAL = C
&CALL PROC=MYPROC PARMS=(PARM1='AB&VAL',PARM2=XY Z)

Once isolated, substitution is performed (if necessary, allowing transparent data to be passed as parameters) and the result placed in the next initialization parameter in the called procedure.

A closing quote of the same type as the opening quote terminates a quoted parameter. Only a comma delimiting the next parameter, or a closing parenthesis terminating the entire parameter list, can immediately follow the closing quote. The entire quoted string is passed to the target procedure unchanged, except that the delimiting quotes are removed.

Normal quote rules apply, that is, two consecutive quotes of the same type as the opening quote are treated as a single occurrence in the resulting string. No substitution is performed on the contents of the quoted string. For example:

PARMS=(&USER,,PROC=&0,”variable ””&FRED”” in error”)

would set the following variables in the called procedure (assume &USER has the value 'ADMIN', &0 'MYPROC', and &FRED 'xyz'):

&1 ADMIN
&2
&3 PROC=MYPROC
&4 variable ”&FRED” in error

&RETCODE or &END in the called procedure sets the return codes.

Note: If used, the PARMS operand must be the last operand on the &CALL statement.

Example: &CALL

&CALL PROC=PROC01 SHARE=(???,msg(1,10),VARS>) +
      PARMS=(&USER,,”inactive”)