Examples: Communicate between persistent procedures
- Last Updated: April 15, 2024
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
In this section, you extend the test windows to see a couple of different ways persistent procedures can communicate with one another.
To add a fill-in field to the main window to locate and manipulate one of the Order windows:
(You just add code to hide or view it alternately, just to show that you can access it.)
- Open h-OrderWin.w and add this statement to the main block (after
RUN enable_UI.) to save off the Order Number in the procedure’sPRIVATE-DATAattribute:ASSIGN THIS-PROCEDURE:PRIVATE-DATA = STRING(OrderNum). - Open h-CustOrderWin6.w and add a fill-in to the window. Call it iOrderWin and give it the label Show/Hide Order.
- Define this
LEAVEtrigger for the new fill-in:DO: DEFINE VARIABLE hProc AS HANDLE NO-UNDO. DEFINE VARIABLE hWin AS HANDLE NO-UNDO. hProc = SESSION:FIRST-PROCEDURE. DO WHILE VALID-HANDLE(hProc): IF hProc:FILE-NAME = "h-OrderWin.w" AND hProc:PRIVATE-DATA = iOrderWin:SCREEN-VALUE THEN DO: hWin = hProc:CURRENT-WINDOW. hWin:HIDDEN = IF hWin:HIDDEN THEN NO ELSE YES. LEAVE. END. hProc = hProc:NEXT-SIBLING. END. END.This trigger block walks through the persistent procedure list managed through the
SESSIONhandle. When it comes to an instance of h-OrderWin.w whosePRIVATE-DATAattribute matches the value in the fill-in, it saves off itsCURRENT-WINDOWattribute, which is the handle of the procedure’s window. If the window is currently hidden it is viewed, and vice versa. - Save the changes and test them out:
- Run h-CustOrderWin6.w.
- Click the Order Detail button for a few different Orders.
- Enter one of the Order numbers into the Save/Hide Order fill-in and tab out of it. The window displaying that Order should disappear, or reappear if it is already hidden.
This is a simple example of how to use the SESSION procedure list to
locate a procedure you are interested in, and then either manipulate that procedure
object or make a request of it in some way.
The next example goes in the opposite direction. Rather than locating one of the Order windows from the main window, you add code to the Order window procedure to request the handle of another procedure from the main window. It then uses that handle to reposition the other Order window. A new internal procedure in the main window provides an interface the Order window can use to get the handle it needs.