IBM AS/400 Manuel D’Utilisation

Page de 489
 
 
Passing Prototyped Parameters
 
Examples of Free-Form Call
For examples of using the CALLP operation, see:
¹
Figure 22 on page 41
¹
Figure 43 on page 97
¹
Figure 105 on page 212
¹
Figure 70 on page 144
¹
Figure 117 on page 242
For examples of calling by using an expression, see:
¹
Figure 4 on page 10
¹
Figure 19 on page 39
¹
Figure 38 on page 79
¹
Figure 105 on page 212
Passing Prototyped Parameters
When you pass prototyped parameters:
¹
The compiler verifies, when compiling both the caller and the callee, that the
parameter definitions match, provided as both are compiled using the proto-
type.
¹
Fewer specifications are needed, since you do not need the PARM operations.
This section discusses the various options that are available when defining proto-
typed parameters, and the impact of these options on the call interface.
Parameter Passing Styles
Program calls, including system API calls, require that parameters be passed by
reference. However, there is no such requirement for procedure calls. ILE RPG
allows three methods for passing and receiving prototyped parameters:
 
¹
By reference
 
¹
By value
¹
By read-only reference
Parameters that are not prototyped may only be passed by reference.
Passing by Reference
The default parameter passing style for ILE RPG is to pass by reference. Conse-
quently, you do not have to code any keywords on the parameter definition to pass
the parameter by reference. You should pass parameters by reference to a proce-
dure when you expect the callee to modify the field passed. You may also want to
pass by reference to improve run-time performance, for example, when passing
large character fields. Note also that parameters that are passed on external
program calls can only be passed by reference.
   
Chapter 10. Calling Programs and Procedures
135