Progress
Programming
Handbook
Working with Persistent Procedures
If you do not specify handle when you create a persistent procedure, you can obtain the handle for the procedure using the SESSION system handle. Progress maintains all handles to persistent procedure instances in a chain that you can access. The SESSION handle has two attributes, FIRST–PROCEDURE and LAST–PROCEDURE, that provide access to the first and last persistent procedures (respectively) that are created. These attributes return procedure handles that you can use to reference attributes of each persistent procedure context. For a complete list of these attributes, see the THIS–PROCEDURE System Handle reference entry in the Progress Language Reference .
For example, using the NEXT–SIBLING attribute with the FIRST–PROCEDURE handle value or the PREV–SIBLING attribute with the LAST–PROCEDURE handle value, you can follow the entire chain of persistent procedure handles to locate the one you want. Note that PREV–SIBLING of FIRST–PROCEDURE and NEXT–SIBLING of LAST–PROCEDURE specify invalid handles to terminate the chain. You can check the validity of any procedure handle value in the chain using the VALID–HANDLE function. It returns TRUE for a valid value and FALSE for an invalid value.
The PRIVATE–DATA attribute is especially helpful in identifying a particular persistent procedure in the chain. When initially created with the RUN statement, a persistent procedure can set this attribute to a unique character value that helps identify its context to other procedures. You can use shared data to help manage the values for this private data. Note that the FILE–NAME attribute might not be sufficient to identify a specific persistent procedure instance, because you can create multiple instances of the same persistent procedure.
Other attributes of procedure handles that help manage persistent procedures include the PERSISTENT, CURRENT–WINDOW, and INTERNAL–ENTRIES attributes. When used with the THIS–PROCEDURE handle, the PERSISTENT attribute returns TRUE if the current procedure is being run persistently. This is useful if you want to write a procedure to run either persistently or non-persistently, providing different code options for each mode of execution.
The CURRENT–WINDOW attribute allows you to assign a unique current window to a procedure context that never changes as long as the procedure remains in scope or until you reset it. This is especially useful for persistent procedures that maintain their own windows. For more information, see Windows."
The INTERNAL–ENTRIES attribute returns a comma-separated list of all the internal procedures defined within the specified external procedure. This is helpful to identify the functional capabilities (internal procedures) provided to your application by each type of persistent procedure that you create. The GET–SIGNATURE method returns the type and parameters of a specified internal procedure.
For example, this code fragment uses several attributes to select persistent procedures that participate in the application user interface, and makes their current windows visible:
For more information on attribute references, see Widgets and Handles."
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |