Progress
Language Tutorial
for Windows
Using Persistent Procedures
What you need is a technique for modularizing the content of the main procedure. For example, suppose you have a collection of internal procedures in the main procedure that acts as a function library for the external procedures. If you move those internal procedures into a separate procedure file and then call that procedure from the main procedure during startup, what happens?
Progress scopes all resources defined in a procedure to that procedure. The sum of the interface objects, data structures, and internal procedures is called the context of the procedure. The context of the procedure is only available during the life of the procedure. So, when the procedure of internal procedures mentioned above finishes executing, all the resources it defines are unscoped.
Progress has another type of procedure that creates a context that lasts beyond the execution of the procedure. This type of procedure is known as a persistent procedure. The context of a persistent procedure lasts until you explicitly delete it.
Persistent procedures promote modularity of application functionality. For example, you could have several persistent procedures that contained related groups of internal procedures. This technique essentially lets you have loadable and unloadable libraries of functions. This ability gives you the modularity you need and allows you to manage your system resources.
Later in the chapter, you’ll learn the specifics of programming persistent procedures. For now, here’s a quick description of how they work. First, you instantiate a procedure context by using the PERSISTENT option of the RUN statement. You can provide the RUN statement with a HANDLE variable to hold a pointer to the context. A procedure context created in this way is a self-contained context. Your code manages the communication between this module and any other modules currently running. The HANDLE variable is the bridge between contexts.
The Progress SESSION handle contains two attributes named FIRST-PROCEDURE and LAST-PROCEDURE. These two attributes allow you to access the beginning and end of the chain of persistent procedures. Together with the NEXT-SIBLING and PREV-SIBLING attributes of the procedure HANDLE variable, you can move through the chain of persistent contexts.
The DELETE PROCEDURE statement lets you delete persistent contexts.
Finally, you should know that you can run each procedure persistently many times. Each separate call with the RUN statement creates a separate context. For situations where you choose to use this technique, you’ll need to create a management system so that you can differentiate between the different instances of the same procedure.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |