ILE RPG Language Reference
If a prototyped program or procedure has call parameters or a return value, then
a procedure interface definition must be defined, either in the main
source section (for a cycle-main procedure) or in the subprocedure
section. If a prototype was specified, the procedure
interface definition repeats the prototype information within
the definition of a procedure. Otherwise, the procedure interface
provides the information that allows the compiler to implicitly define
the prototype. The procedure interface is used to declare the entry
parameters for the procedure and to ensure that the internal definition
of the procedure is consistent with the external definition (the prototype).
The following rules apply to procedure interface definitions.
- The name of the procedure interface, specified in positions
7-21, is required for the cycle-main procedure. It is optional for
subprocedures. If specified, it must match the name specified in positions
7-21 on the corresponding prototype definition.
- Specify PI in the Definition-Type entry (positions
24-25). The procedure-interface definition can be specified anywhere
in the definition specifications. In the cycle-main procedure, the
procedure interface must be preceded by the prototype that it refers
to. A procedure interface is required in a subprocedure if the procedure
returns a value, or if it has any parameters; otherwise, it is optional.
- Any parameter definitions, indicated by blanks in positions 24-25,
must immediately follow the PI specification.
- Parameter names must be specified, although they do not have to
match the names specified on the prototype.
- All attributes of the parameters, including data type, length,
and dimension, must match exactly those on the corresponding prototype
definition.
- To indicate that a parameter is a data structure,
use the LIKEDS keyword to define the parameter with the same subfields
as another data structure.
- The keywords specified on the PI specification and
the parameter specifications must match those specified on the prototype,
if the prototype is explicitly specified.
- If a prototype is not specified, the EXTPGM or EXTPROC
keyword may be specified for the procedure interface.
TIP
If a module contains calls to a prototyped program or procedure that is defined
in a different module, then there must be a prototype definition
for each program and procedure that you want to call. One way of minimizing
the required coding is to store shared prototypes in /COPY files.
If you provide prototyped programs or procedures to other users,
be sure to provide them with the prototypes (in /COPY files) as well.
[ Top of Page | Previous Page | Next Page | Contents |
Index ]