IBM AS/400 Frozen Dessert Maker User Manual


 
Using a Prototyped Call
Table 10. Parameter Passing Options
Parameter Option Prototyped Not
Prototyped
See Page
Compile-time parameter
checking
Yes 135
Pass by reference Yes Yes 135
Pass by value Yes (b) 136
Pass by read-only reference Yes 137
Pass operational descriptors Yes (b) Yes (b) 138
Pass *OMIT Yes (b) Yes (b) 139
Control parameter omission Yes Yes 140
Get number of passed parame-
ters
Yes Yes 141
Disallow incorrect parameter
length
Yes 145
Note: (b) – applies to bound procedures only.
Using a Prototyped Call
A prototyped call is one for which there is a prototype that is available to do param-
eter checking. It has a much simpler call interface and offers more function. For
example, using a prototyped call you can call (with the same syntax):
Programs that are on the system at run time
Exported procedures in other modules or service programs that are bound in
the same program or service program
Subprocedures in the same module
In RPG, prototyped calls are also known as free-form calls. Free-form call refers to
the call syntax where the arguments for the call are specified using free-form
syntax, much like the arguments for built-in functions. It contrasts with fixed-form
call, where the arguments are placed in separate specifications. There are two
ways to make a free-form call, depending on whether there is a return value that is
to be used. If there is no return value, use the CALLP operation. If there is one,
and you want to use the value that is returned, then place the prototyped procedure
within an expression, for example, with EVAL. If you use CALLP to a procedure
that returns a value, the return value is ignored.
Note: Only prototyped procedures can return values; prototyped programs cannot.
For information on passing prototyped parameters, see “Passing Prototyped
Parameters” on page 135.
Using the CALLP Operation
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 fol-
lowing free-form syntax:
C CALLP NAME{ (PARM1 {:PARM2 ...}) }
Chapter 10. Calling Programs and Procedures 133