Objects or classes can use events to trigger event handler
methods in other objects or classes. One method can be called by any number of
users in a normal method call. When an event is triggered, any number of event
handler methods can be called. Until runtime, the link between the trigger and
the handler is not established. The calling program determines the methods that
it wants to call in a normal Method call and it must exist. With events, the
handler determines the events to which it wants to react. It is not necessary
that for every event there has to be a handler method registered.
With the help of RAISE EVENT statement, the events of a
class can be triggered in the methods of the same class. You can declare a
method of the same or a different class as an event handler method for the
event <evt> of class <class> by using the addition FOR EVENT
<evt> OF <class>. Events have a similar parameter interface to
methods, but only have output parameters. These parameters are passed by the
trigger (RAISE EVENT statement) to the event handler method, which receives
them as input parameters.
Using the SET HANDLER statement, the link between trigger
and handler is established dynamically in a program. The trigger and handlers
can be objects or classes, depending on whether you have instance or static
events and event handler methods. When an event is triggered, the corresponding
event handler methods are executed in all registered handling classes.