Progress
Programming
Handbook
Trigger Scope
The scope of a trigger is that part of an application during which the trigger can be executed. The scope of a definitional trigger is the same as the scope of the widget.
By default, the scope of a run-time trigger is the nearest containing procedure, subprocedure, or trigger block in which it is defined. You might want a run-time trigger to remain active beyond the procedure or trigger that defines it. You can do this by setting up a persistent trigger. Like a definitional trigger, a persistent trigger remains active as long as the widget exists. A persistent trigger allows you to create the equivalent of a definitional trigger for a dynamic widget.
Table 16–6 summarizes the scope for each type of trigger.
A persistent trigger must consist only of a single RUN statement. The RUN statement can invoke an internal or external procedure. The procedure can have one or more input parameters, but must not have any output or input/output parameters. You must ensure that the specified procedure is available whenever the trigger is invoked. For example, if you use an internal procedure, you must ensure that the trigger is not invoked from another external procedure.
NOTE: If you pass parameters to a persistent trigger procedure, the parameter values are evaluated once when the trigger is defined. They are not reevaluated each time the trigger executes. You cannot, for example, pass the SELF system handle as a parameter to the persistent trigger.The following procedure creates a button within the CHOOSE trigger for make–butt. Normally, any trigger assigned to the new button remains active only until execution of the CHOOSE trigger ends. To maintain the new trigger beyond the CHOOSE trigger, you must use a persistent trigger:
The example allows the user to create up to 100 dynamic buttons. Each time the user chooses make–butt, the value of num–butts is incremented, the height of the frame is recalculated to ensure the new button will fit, and the new button is created. When the user chooses one of the dynamic buttons, the procedure displays a message.
If after defining a persistent trigger for an event-widget pair you define a nonpersistent trigger for that same pair, the nonpersistent trigger overrides the persistent trigger. However, after the nonpersistent trigger goes out of scope (or is reverted), the persistent trigger becomes active again.
NOTE: Because persistent triggers remain active beyond the scope of the defining procedure, you must ensure that any variables, frames, or buffers referenced by the trigger are available whenever it is active.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |