IBM AS/400 Frozen Dessert Maker User Manual


 
Program/Procedure Call Overview
ples of using procedure pointers, see the section on the procedure pointer data
type in
ILE RPG for AS/400 Reference
.
You use the CALLP or both the CALLB and PARM operations to make a procedure
call. You can also call a prototyped procedure with an expression if the procedure
returns a value. If you use the CALLB and PARM operations, then the compiler
cannot perform type checking on the parameters, which may result in run-time
errors.
The Call Stack
The call stack is a list of call stack entries, in a last-in-first-out (LIFO) order. A call
stack entry is a call to a program or procedure. There is one call stack per job.
When an ILE program is called, the program entry procedure is first added to the
call stack. The system then automatically performs a procedure call, and the asso-
ciated user's procedure (the main procedure) is added. When a procedure is called,
only the user's procedure (a main procedure or subprocedure) is added; there is no
overhead of a program entry procedure.
Figure 58 shows a call stack for an application consisting of an OPM program
which calls an ILE program. The RPG main procedure of the ILE program calls an
RPG subprocedure, which in turn calls a C procedure. Note that in the diagrams in
this book, the most recent entry is at the bottom of the stack.
Program
Entry Proc.
Sub-
Procedure
Program Call
CALL STACK
PEP
Procedure Call (by system)
Procedure Call
Procedure
Procedure
Procedure
Procedure Call
Program A
OPM
OPM
C Module
ILE
RPG Module
ILE
ILE
ILE
ILE
Main
Procedure
Procedure
Figure 58. Program and Procedure Calls on the Call Stack
Note: In a program call, the calls to the program entry procedure and the user
entry procedure (UEP) occur together, since the call to the UEP is auto-
matic. Therefore, from now on, the two steps of a program call will be com-
bined in later diagrams involving the call stack in this and remaining
chapters.
Chapter 10. Calling Programs and Procedures 129