Kbase P11558: How to do trap a QUIT event, override default behaviour and
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  02/07/2003 |
|
Status: Unverified
GOAL:
How to do trap a QUIT event, override default behavior and apply a normal QUIT?
FIX:
The following code does not work and will result in an infinite loop. Indeed, because of the 'ON QUIT UNDO, RETRY' no QUIT can be returned to the calling level within the RETRY block:
PROCEDURE makeQuit:
QUIT.
END PROCEDURE.
PROCEDURE theQuitCase:
this:
DO TRANSACTION ON QUIT UNDO, RETRY this:
MESSAGE 'before retry'.
IF RETRY THEN DO: /* Try to override/disable quit-handling here */
/* ...some cleanup code... */
/* Infinite loop protection, */
MESSAGE 'Abort this test ?' VIEW-AS ALERT-BOX QUESTION
BUTTONS YES-NO UPDATE exitThatProblem AS LOG.
IF exitThatProblem THEN RETURN.
QUIT. /* wants to resume "normal" quit processing here...
=> RETURN the QUIT to the level above
=> but it will lead to an other retry*/
END.
MESSAGE 'before RUN makeQuit'.
/* ...some code... */
RUN makeQuit.
END.
END.
/* main block */
DO ON QUIT UNDO, LEAVE:
RUN theQuitCase.
MESSAGE 'after the run...'
"The developer does not want the flow to get there"
"BUT it DOES ... because QUIT could not be dispatched :("
VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
END.
The solution is to do the QUIT outside of the ON QUIT UNDO,RETRY block as illustrated bellow:
PROCEDURE theQuitCase:
DEFINE VARIABLE ReturnQuit AS LOGICAL NO-UNDO.
this:
DO TRANSACTION ON QUIT UNDO, RETRY this:
MESSAGE 'before retry'.
IF RETRY THEN DO: /* override quit-handling here */
/* ...some cleanup code... */
ReturnQuit = YES.
LEAVE this.
END.
MESSAGE 'before RUN makeQuit'.
/* ...some code... */
RUN makeQuit.
END.
IF ReturnQuit THEN QUIT.
END.
Note that the trend is more about relying on super procedure override.