Kbase P4797: How to leave a loop when the Escape key (endkey) is pressed?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/29/2008 |
|
Status: Verified
GOAL:
How to leave a loop when the Escape key (endkey) is pressed?
GOAL:
How to run a trigger block on the endkey event in a loop?
GOAL:
How to respond to the endkey event in a loop and run trigger block?
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
All Supported Operating Systems
FIX:
Here are two examples for leaving a loop when the endkey is pressed:
Example 1:
/* Use the ON ENDKEY phrase for a block as shown below: */
loopA:
FOR EACH customer:
DISPLAY NAME customer.custnum WITH FRAME c.
DOWN WITH FRAME c.
FOR EACH order OF customer ON ENDKEY UNDO, LEAVE LoopA:
DISPLAY order WITH FRAME o.
DOWN WITH FRAME o.
END.
END.
Example 2:
/* The sample code below will trap the endkey event and run the "test" procedure trigger block should it occur while processing the DO block: */
def var lQuit as logical no-undo.
def var i as int no-undo.
/* 1. trap endkey event and set lQuit to true */
on F4, end-error, endkey anywhere
lQuit = true.
/* 2. procedure block that checks for lQuit value in every iteration */
do i = 1 to 1000000 on error undo, retry on endkey undo, retry:
process events.
if lQuit then do:
run test.
leave.
end.
end.
if lQuit then
message "hi there" view-as alert-box.
procedure test:
message "hi from test" view-as alert-box.
end procedure.