Progress
Programming
Handbook


Procedure Context and the Procedure Call Stack

In the previous examples, when p-exprc2.p calls p-exprc1.p, p-exprc2.p waits on the procedure call stack until p-exprc1.p completes execution and returns. The procedure call stack is an internal memory structure that Progress uses to keep track of procedure context and scope. When one procedure calls another, Progress saves the context of the calling procedure on the call stack. The called procedure then establishes the new current context. When the called procedure returns, Progress re-establishes the context of the calling procedure as the current context.

NOTE: Triggers also execute and interact with the call stack like procedures. When a trigger executes in response to an event, its context becomes the current context. For more information, see Database Triggers."

Figure 3–1 shows how the procedure call stack maintains procedure context and scope in a Progress client. It shows an application, your-app.p, running from the Procedure Editor, which is also on the stack. As each procedure calls the next, its context is saved on the stack.

Figure 3–1: Procedure Call Stack

Progress can save any number of procedures on the call stack (that is, you can nest any number of procedure calls), depending on the size of each saved context and the size of the call stack. The size of the context depends on the size and number of definitions created and maintained by the procedure. The size of the call stack depends on the setting of the Nested Blocks (nb) startup parameter and the Stack Size (s) startup parameter (in 1K units). The default for nb is 50 and the default for s is 40. For more information on nb and s, see the Progress Startup Command and Parameter Reference.

NOTE: There is a distinction between procedure scope and context. While the procedure context is the actual environment in which a procedure executes, the procedure scope is the duration that its context remains available to the application. For example, in Figure 3–1, while the context of your-app.p and subprc1.p might be invisible to each other, subprc1.p remains within the scope of your-app.p.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095