skip to main content
OpenEdge Development: ADM and SmartObjects
Advanced ADM Topics : Writing local event procedures and functions
Writing local event procedures and functions
An event procedure is a procedure that executes when a particular event occurs. This is sometimes accomplished through the PUBLISH/SUBSCRIBE functionality, as follows:
1. SmartObjects that need to know about an event SUBSCRIBE to the event. (The addLink procedure does this at startup.)
2. When an event occurs, a SmartObject PUBLISHes the event.
3. This action notifies all subscribing SmartObjects that the event occurred.
Sometimes, however, this happens simply when a SmartObject RUNs an internal procedure or invokes a user‑defined function. In either case, the procedure or function being executed normally is implemented in a separate super procedure. See the “Super procedures” section.
The super procedure functionality allows you to write a local version of an ADM internal procedure or function in a SmartObject master procedure file that augments or overrides default ADM events. When the ADM runs an internal procedure or function, Progress 4GL looks at the SmartObject and its super procedures, starting with a local version if there is one, and runs the first one it finds. If this super procedure performs a RUN SUPER or SUPER( ), the 4GL looks further up the super procedure chain to find the next version to run. A local version of an ADM procedure can execute code before, after, or instead of the more standard behavior of the internal procedures and functions in ADM super procedures.
Writing a local event procedure
To write a local event procedure in the AppBuilder:
1. Invoke the Code Section Editor, go to the Procedures code section, and choose the New button. The New Procedure dialog box appears:
2. Activate the Override radio button. The AppBuilder populates the Name combo box list with the ADM event procedures available in the super procedures for the SmartObjects:
3. Select the ADM event procedure for which you want to write a local version, then choose OK. The AppBuilder returns you to the Code Section Editor and creates a procedure with the same name. If this procedure already exists, the AppBuilder displays the existing code section.
The default code for a local event procedure always executes the standard version of the procedure, located in one of the SmartObject’s super procedures. For example, for addLink, the following line appears in the local version:
RUN SUPER ( INPUT phSource, INPUT pcLink, INPUT phTarget).
This allows you to put code before or after the standard event procedure call or not run the code at all (by commenting it out).
Note: Do not suppress the standard event procedure by removing the RUN SUPER statement unless you are sure that you understand what it does and that you replace it correctly.
Writing a local event function
With one exception, you write a local event function in the same way you write a local event procedure, as described in the “Writing a local event procedure” section. The exception is that in Step 1, you go to the list of functions in the Code Section Editor instead of the Procedures code section.