Prototyped Calls

With a prototyped call, you can call (with the same syntax):

If the program or procedure is not defined in the same module as the call, a prototype must be included in the definition specifications of the program or procedure making the call. It is used by the compiler to call the program or procedure correctly, and to ensure that the caller passes the correct parameters.

If the procedure is defined in the same module as the call, it is not necessary to explicitly define a prototype. The prototype can be implicitly defined by the compiler using the information specified by the Procedure Interface for the procedure.

When a program or procedure is prototyped, you do not need to know the names of the data items used in the program or procedure; only the number and type of parameters.

Prototypes improve the communication between programs or procedures. Some advantages of using prototyped calls are:

Figure 174 shows an example using the prototype ProcName, passing three parameters. The prototype ProcName could refer to either a program or a procedure. It is not important to know this when making the call; this is only important when defining the prototype.

Figure 174. Sample of CALLP operation
 /FREE
 // The following calls ProcName with the 3
 // parameters CharField, 7, and Field2:
      ProcName (CharField: 7: Field2);

 // If you need to specify operation extenders, you must also
 // specify the CALLP operation code:
      CALLP(e) ProcName (CharField: 7: Field2);
 /END-FREE

When calling a procedure in an expression, you should use the procedure name in a manner consistent with the data type of the specified return value. For example, if a procedure is defined to return a numeric, then the call to the procedure within an expression must be where a numeric would be expected.

For more information on calling programs and procedures, and passing parameters, see the appropriate chapter in the IBM Rational Development Studio for i: ILE RPG Programmer's Guide. For more information on defining prototypes and parameters, see Prototypes and Parameters.



[ Top of Page | Previous Page | Next Page | Contents | Index ]