Progress
Programming
Handbook


Reverting Triggers

To cancel a trigger definition before it goes out of scope, use the REVERT option of the ON statement. The REVERT option cancels any trigger for the event-widget pair defined in the current procedure or trigger.

In the following procedure, p-rev.p, two triggers are defined for the selection of hello–button: one in the outer procedure and one in the internal procedure, inner. At the first WAIT–FOR statement within inner, the local trigger is active. Therefore, when the user selects the button, “Inner message” is displayed. Before the second WAIT–FOR, this trigger is reverted. The trigger from the outer procedure becomes active again. Therefore, when the user selects the button again, “Outer message” is displayed.

p-rev.p
DEFINE BUTTON hello-button LABEL "Greeting".
DEFINE BUTTON revert-button LABEL "Revert".

FORM
   hello-button revert-button
   WITH FRAME butt-frame.

ON CHOOSE OF hello-button IN FRAME butt-frame
   DO:
      MESSAGE "Outer message".
   END.

ENABLE hello-button WITH FRAME butt-frame.
RUN inner.

PROCEDURE inner:
   ON CHOOSE OF hello-button IN FRAME butt-frame
      DO: 
         MESSAGE "Inner message".
      END.

   ENABLE revert-button WITH FRAME butt-frame.  
   
   WAIT-FOR CHOOSE OF revert-button.
   
   ON CHOOSE OF hello-button IN FRAME butt-frame
      REVERT.

   DISABLE revert-button WITH FRAME butt-frame.
   WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.
END PROCEDURE. 

NOTE: You cannot use REVERT to cancel a persistent trigger. Instead, you must set up a replacement persistent trigger where the procedure consists only of a RETURN statement.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095