CL Command Reference - CALLPRC
CL Command List > CALLPRC Reference
Description:
The Call Bound Procedure (CALLPRC) command calls a bound procedure named on the command, and passes control to it. Optionally, the procedure issuing the CALLPRC command can pass parameters to the called procedure. The CALLPRC command can be used in compiled ILE control language (CL) programs and modules. If the called procedure returns a value, such as an error code, the returned value can be stored into a CL variable by specifying the CL variable name for the CL variable for returned value (RTNVAL) parameter.
Each parameter value passed to the called procedure can be a character string constant, a numeric constant, a logical constant, a floating-point constant, or a CL variable. If a floating-point constant is specified, the value is converted to double-precision format and passed to the called program. If parameters are passed, the value of the constant or variable is available to the program that is called. Parameters cannot be passed in any of the following forms: lists of values, qualified names, expressions, or keyword parameters. Up to 300 parameters can be passed to the called procedure.
Note: Although the CALLPRC command will allow up to 300 parameters to be passed, the number that the called procedure can accept will depend on the language of the called procedure. For example, a CL procedure cannot accept more than 255 parameters.
If parameters are passed to a procedure using the CALLPRC command, the values of the parameters are passed in the order in which they appear on the CALLPRC command; this order must match the order in which they appear in the parameter list in the called procedure.
Parameters may be passed by reference or passed by value.
Restrictions:
. The CALLPRC command is valid only within an ILE CL module.
Examples:
Example 1: Calling a Procedure
CALLPRC PRC(PAYROLL)
The procedure named PAYROLL is called with no parameters being passed to it. The PAYROLL procedure does not return a value.
Example 2: Passing a Character Constant
CALLPRC PRC(PAYROLL) PARM(กฏ1กฏ)
The procedure named PAYROLL is called with a character constant passed as a quoted string. The PAYROLL procedure does not return a value.
Example 3: Passing Parameters
CALLPRC PRC(PAYROLL) PARM(CHICAGO 1234 &VAR1)
RTNVAL(*NONE)
The procedure named PAYROLL is called. The calling procedure passes three parameters: a character string (CHICAGO), a decimal value (1234.00000), and the contents of the CL variable &VAR1. The attributes of the variable determine the attributes of the third parameter. The PAYROLL procedure does not return a value.
Example 4: Calling Procedure with Floating-Point Values
CALLPRC PRC(PRC1) PARM(1.5E3 *INF) RTNVAL(&RVAL)
The procedure named PRC1 is called with two double-precision floating-point values being passed to it. The returned value is stored in variable &RVAL.
Example 5: Ignoring the Return Value of a Procedure
CALLPRC PRC(PRC1) PARM(1.5E3 *INF) RTNVAL(*NONE)
The procedure named PRC1 is called with two double-precision floating-point values being passed to it. The returned value is ignored and therefore unavailable to the calling procedure.
Example 6: Calling a Procedure that Returns a Binary Number Using %BIN
CALLPRC PRC(RTNINT) RTNVAL(%BIN(&RTNV 1 4))
The procedure named RTNINT returns a 4-byte binary value. It is stored in the first four bytes of variable &RTNV. Variable &RTNV is of type *CHAR and has a length of at least 4.
Example 7: Calling a Procedure that Returns a Binary Number Using an Integer CL Variable
DCL VAR(&VAR2) TYPE(*INT) LEN(4)
:
CALLPRC PRC(RTNINT) RTNVAL(&VAR2)
The procedure named RTNINT returns a 4-byte binary value, which is stored in the 4-byte signed integer CL variable &VAR2
Example 8: Calling a Procedure Passing a Parameter By Value
DCL VAR(&POS) TYPE(*INT) LEN(2)
:
CALLPRC PRC(SCAN_STRING) PARM((&STR1 *BYREF) (กฏ กฏ *BYVAL))
RTNVAL(&POS)
The procedure named SCAN_STRING is called with two parameters. The CL variable &STR1 is passed by reference and the constant character string กฏ กฏ (one blank) is passed by value to SCAN_STRING. Procedure SCAN_STRING must be defined to receive the first parameter as a pointer to a character string and the second parameter as a one-byte character string. The SCAN_STRING procedure returns a 2-byte binary value, which is stored in the 2-byte signed integer CL variable &POS.