


The ACUCOBOL-GT compiler in its HP e3000 compatibility mode supports the following HP e3000 COBOL extensions to the CALL statement.
Format 4 (HP e3000 COBOL)
CALL { identifier-1 } [ USING { \\ } ... ]
{ [ INTRINSIC ] literal-1 } { @identifier-2 }
{ identifier-2 }
{ literal-2 }
{ \identifier-2\ }
{ \literal-2\ }
[ GIVING identifier-n ]
[ ON OVERFLOW statement-1 [ END-CALL ] ]
Format 5 (HP e3000 COBOL)
CALL { identifier-1 } [ USING { \\ } ... ]
{ [ INTRINSIC ] literal-1 } { @identifier-2 }
{ identifier-2 }
{ literal-2 }
{ \identifier-2\ }
{ \literal-2\ }
[ GIVING identifier-n ]
[ ON EXCEPTION statement-1 ]
[ NOT ON EXCEPTION statement-2 ]
[ END-CALL ]
Syntax Rules
1. Identifier-1 is an alphanumeric data item whose value is a program name. See General Rules (below) for a description of conditions that may occur when you use this operation.
2. Literal-1 is a nonnumeric literal whose value is either an operating system intrinsic name or a program name. When you are naming an intrinsic, literal-1 must be preceded by the keyword INTRINSIC.
3. "\\" represents a null value passed as a parameter to an intrinsic or to a System Programming Language (SPL) program that includes the OPTION VARIABLE clause. When the intrinsic option is not specified, the compiler assumes a one-word parameter.
4. @identifier-2 indicates that the byte address of the data item represented by identifier-2 is to be passed as a parameter. These types of parameters may be passed only to non-COBOL programs.
5. Identifier-2 is the name of any data item in the calling program, or is a file named in an FD-level entry in the File Section of your program.
6. Identifier-2 cannot be a function-identifier (i.e., it cannot reference an intrinsic function).
General Rules
1. When you use the identifier-1 form of the CALL statement, the value of identifier-1 determines which subprogram is called. When the program is executed, an attempt is made to load the subprogram. If the load fails, an exception condition occurs.
2. Identifier-2 must be described in the File, Working-Storage, or Linkage section of your program. When this value is passed to another program, it is passed by reference.
3. If identifier-2 names a file, the called program must not be a COBOL program.
4. \identifier-2\ and \literal-2\ indicate that the literal or data item enclosed in backslashes is to be passed by value to the called program or intrinsic. This may be used only when the called program is not a COBOL program. If an identifier is used in this way, it must represent a numeric data item of not more than 18 digits.
5. Identifier-n is the name of a binary data item in the calling program. It is used in calls to non-COBOL programs and in calls to COBOL programs that return a value in the RETURN-CODE special register. Identifier-n cannot be a function-identifier (i.e., it cannot refernce an intrinsic function).
Calling intrinsics
The INTRINSIC phrase is used to indicate that the CALL statement is calling an operating system intrinsic function, rather than a subprogram. When the INTRINSIC phrase is used, literal-1 must be used and must name an operating system intrinsic. The USING phrase specifies the various parameters to be passed to the intrinsic. When the intrinsic is a "typed procedure," the GIVING phrase specifies the parameter to be returned by the intrinsic.
As with subprograms, the parameters passed to intrinsics are specified by position. If a parameter of an intrinsic is optional, and you do not want to pass a value for that parameter, you must specify two consecutive backslashes ("\\") in the position within the USING phrase of the CALL statement that corresponds to that parameter's position.
Unlike subprograms, if an intrinsic expects a parameter to be passed by value rather than by reference, you don't need to enclose the literal or identifier in backslashes. The intrinsic automatically assumes that the parameter is being passed by value.
The following special relation operator can be used after a call to an intrinsic to check the condition code returned by an intrinsic:
mnemonic-name { [ NOT ] { < } } 0
{ { = } }
{ { > } }
{ { >= } }
{ { <= } }
{ { <> } }
When CALL INTRINSIC is used for intrinsics in a system file:
the special symbols "@" and "\" are optional. data conversions for parameters passed by value are performed automatically.
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.