Triggers as event-driven code
- Last Updated: December 20, 2023
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
There is one important thing to note about the trigger blocks. In Introduction to ABL you learned that language statements are generally
executed or processed in the order in which they appear in the procedure. Now you need
to think about the difference between statements being executed and statements
merely being processed. Definitional statements such as the DEFINE
VARIABLE and DEFINE BUTTON statements are not executed at
all. They just tell the ABL Virtual Machine (AVM) to set up the structures they define
for later use. The trigger blocks, however, are executable blocks of code, but they are
not executed when they are first encountered. They are just set up to be executed when
the event they are defined for occurs. You can think of the ABL compiler marching down
through the procedure and defining the r-code for each executable statement in sequence.
When it encounters a trigger block, it sets aside a special part of the r-code with
those statements in it, keyed by the event that triggers the code.
This concept is fundamental to the nature of OpenEdge applications. These applications are called event-driven, because to a large extent the procedures in the application just set up blocks of code, and even entire procedures, to be available in memory when user-initiated events call for them.