USING phrase (non-COBOL subprograms)

Data is passed from the calling program to the called program on a positional basis, rather than by name. Therefore, the third name in a USING phrase of a calling program corresponds to the third name in the arguments of the called program.

This positional correspondence extends to non-COBOL called programs. Thus, for example, if the called program is a Pascal program, then the names in the parameter list of the procedure declaration in that program are identified with those data items whose names appear in the corresponding position of the USING phrase in the calling program.

As stated above in the description of identifier-2, identifier-3, and so forth, these identifiers may name files to be passed to a called program. Furthermore, although you can enclose such a file identifier between backslashes (which are ignored), preceding it with an @ symbol results in an error.

If the file name from the FD is passed, the file number of that file is passed by value. If the subprogram is an SPL procedure, the procedure parameter corresponding to the file name must be declared as type INTEGER or LOGICAL, and it must be specified as a value parameter. The file must be opened in the calling program.

To pass a data item by value, you must enclose the associated identifier in backslashes. If the value passed is a literal, the backslashes are optional. Passing a data item by value leaves the data item in the calling program unchanged following execution of the called program.

If an identifier is not passed by value (that is, is not enclosed in backslashes), it is passed as a byte pointer (that is, by reference). Thus, the data in the calling program can be altered by the called program if it is passed in this manner. In calls to COBOL programs, this is the standard method of referencing common data.

Two consecutive backslashes ("\\") may be specified in a USING phrase of a CALL statement if the called program is a Pascal procedure with OPTION DEFAULT_PARMS or EXTENSIBLE. Using two consecutive backslashes indicates that a parameter is not being sent and should not be expected.

Whenever an OPTION VARIABLE SPL procedure is called, an additional parameter must be added to the end of the USING parameter list. This parameter is called a bit mask and is used to tell the SPL procedure which parameters are being passed. The bit mask consists of one or two 16-bit binary words, where a 0 represents a missing parameter and a 1 represents an existing parameter (this allows up to 32 parameters to be passed). A parameter in the bit mask must be a numeric data item, and it represents the value derived from the bit mask.

Parameters are matched, starting from the right, in both the bit mask and the USING list, excluding the value in the USING list used for the bit mask parameter. For example,

CALL "SPLPROC" USING \TESTER\ \\ @RESULT \ERROR\ \%13\

The bit mask in this case is 0000000000001011, which is represented by the octal value "\%13\", showing that the fourth, third, and first parameters are being passed, while the second parameter is not being passed.

The bit mask is generated automatically by the compiler if you specify the INTRINSIC option.