You use the CALLP (Call a Prototyped procedure) operation to call a prototyped program
or procedure written in any language. The CALLP operation uses the following
extended-factor 2 syntax:
C CALLP NAME{ (PARM1 {:PARM2 ...}) }
In free-form calculations, you can omit CALLP if there are no operation
extenders. The free-form operation can use either of the following forms:
/free
callp name { (parm1 { :parm2 ...} ) };
name( {parm1 {:parm2 ... }} );
/end-free
To call a prototyped program or procedure follow these general steps:
- Include the prototype of the program or procedure to be called in the
definition specifications.
This step is optional if the procedure is in
the same module as the call, and there are no
other modules that call the procedure.
- Enter the prototype name of the program or procedure in the extended Factor-2
field, followed by the parameters if any, within parentheses. Separate the
parameters with a colon (:). Factor 1 must be blank.
The following example shows a call to a procedure Switch, which changes
the state of the indicator that is passed to it, in this case *IN10..
C CALLP Switch(*in10)
A maximum of 255 parameters are allowed on a program call, and a maximum
of 399 for a procedure call.
You can use CALLP from anywhere within the module. If the keyword EXTPGM
is specified on the prototype, the call will be a dynamic external call; otherwise
it will be a bound procedure call.
Note that if CALLP is used to call a procedure which returns a value, that
value will not be available to the caller. If the value is required, call
the prototyped procedure within an expression.