Progress
Language Tutorial
for Character
Sharing with Persistent Procedures
The persistent procedure is different from parameters and SHARED resources, in that it makes an entire procedure context available to other modules.
It is important to remember that persistent procedures instantiate separate, individual contexts—not one large context in which each context becomes a part of the whole. By using the procedure HANDLE your code can make the separate procedures interact with each other.
The point of the persistent procedure is that what is available to be shared between modules is now under your control. The resources in a persistent procedure can be loaded and unloaded in bulk.
Persistent Procedure Syntax
The first step in creating a persistent procedure, is to define a HANDLE variable to hold the context reference as the following code fragment shows:
The next step is to run an external procedure with the PERSISTENT option of the RUN statement. The diagram below shows the relevant RUN statement syntax.
Progress sets the HANDLE variable you supply to the handle for the procedure context.
This code fragment shows a valid persistent procedure call:
When you are through with a procedure, you need to delete it. This is the syntax for the DELETE PROCEDURE statement.
Here is an example of the delete procedure statement:
There are some other 4GL language elements that help you manage persistent procedures. Table 12–1 describes them.
Persistent Procedure Programming Example
Follow the steps below for a demonstration of persistent procedures.
- Open
lt-12-01.p
and run it. The display shown below appears:
![]()
- Choose Run Procedure 2. An alert box appears informing you that the context for procedure 2 is available. This alert box represents the body of an internal procedure stored in an external procedure file. The internal procedure was accessed and run from the main procedure after the execution of the external procedure was already complete.
- Choose Check Contexts. The filenames of all persistent procedures appear in the display.
- Choose Delete Context 2 and then choose Check Contexts again. The deleted context disappears from the list.
- Choose Exit, and then press SPACEBAR to return to the Procedure Editor.
The code for the main procedure is on the next page. The two external procedures are simply MESSAGE statements inside internal procedures:
The points below help explain the code:
- The HANDLE variables hold the pointers to the persistent procedures.
- This IF statement prevents the user from establishing many separate contexts for each procedure.
- The PERSISTENT option asks Progress to save the procedure, and the SET option provides the handle to the procedure.
- The VALID-HANDLE function takes a HANDLE variable and determines if it is a legal reference to a current persistent procedure.
- This RUN statement uses the IN
handle
syntax to access and run an internal procedure in the persistent procedure context.- The DELETE PROCEDURE statement removes the procedure.
- This trigger runs through the current chain of persistent procedures and records the filenames of each in a string.
- The exit trigger makes sure the procedures are destroyed before exiting the procedure. Because you stored the procedure HANDLE when you ran the procedure, you have programmatic control of that procedure. In this example, you use that HANDLE to explicitly delete any surviving procedure contexts before exiting the main procedure.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |