Exiting a loop

dwolking

New Member
Currently using character based Progress Version 9.1C05.

Problem is allowing a user to terminate a lengthy "for each" or "repeat" loop.

In earlier versions of Progress the following seemed to work to allow the user to exit (We have Ctrl-C disabled for our users):

pause 0 before-hide.

main-loop:
for each customer no-lock:

readkey.
if lastkey = 309
then leave main-loop.

disp
customer.name.

end.

We did have a much slower machine when we were using the previous versions though.

Another thought that also didn't seem to work:

pause 0 before-hide.

main-loop:
for each customer no-lock on endkey undo, leave main-loop:

disp
customer.name.

end.

Any thoughts?

Dan

:confused:
 
You say 9.1C05

Try the PROCESS EVENTS statement.

Just stick it in the loop instead of all the readkey stuff!

pause 0 before-hide.

main-loop:
for each customer no-lock:

PROCESS EVENTS.

disp
customer.name.

end.

This should do the trick.

What it won't do is interrupt a query being built which takes a long time. E.g. using a by which is sorting millions of records.

Enjoy!
 
Excellent and thank you. It seems that "PROCESS" is in our Progress keyword file (excluding it from availability), but I'm requesting that our DBA remove it.

I think this will help a lot. Thanks for taking the time.

Dan
 
Toby,

Finally got a chance to test your suggestion. We were unable to get it to work. We also tried the "PROCESS EVENTS" example right out of the Progress manual. It didn't work either. In both cases the program ignored the F9 event and continued through until it had processed all records in the table. Do you think this might be a difference between Character and GUI Progress? Or perhaps there's a start-up parameter that affects this...

Any thoughts?

Dan Wolking
dwolking@pomeroy.com


Originally posted by toby.Harman
You say 9.1C05

Try the PROCESS EVENTS statement.

Just stick it in the loop instead of all the readkey stuff!

pause 0 before-hide.

main-loop:
for each customer no-lock:

PROCESS EVENTS.

disp
customer.name.

end.

This should do the trick.

What it won't do is interrupt a query being built which takes a long time. E.g. using a by which is sorting millions of records.

Enjoy!
 
At the risk of asking a silly question:

You did put something into the code to trap the event you are looking for didn't you?

Code:
ON F9 ANYWHERE
DO:
   /* Do whatever I want to do when f9 occurs */
END.
 
No such thing as a silly question for me. I'm really kind of new to this event driven stuff so I don't have any real "instincts" for it. I tried your suggestion (see actual code below) and still had the "runaway" effect. It just seems bizarre to me that there doesn't seem to be a way to program an easy interrupt into this thing.

Dan Wolking


on F9 anywhere do:
stop.
end.

pause 0 before-hide.

for each customer no-lock:

process events.

disp
customer.sname.

end.


Originally posted by Crittar
At the risk of asking a silly question:

You did put something into the code to trap the event you are looking for didn't you?

Code:
ON F9 ANYWHERE
DO:
   /* Do whatever I want to do when f9 occurs */
END.
 
Seems strange, I would have expected that to work.

Looking at the code I assume you just keep getting the customer surname displayed?

You could try replacing the stop with an alert message just to check that you are getting into the ON F9. Might also be worthwhile changing the F9 for something else (F4 maybe and making the trap ON END-ERROR ANYWHERE). I don't see why it should make any difference but when in doubt clutch at straws lol.

:rolling:
 
I've just tried the code you published (substituting a large table from my database for customers) and it worked perfectly.

Not sure what else to suggest.

:(
 
I think I sorted it!

try this
<pre>
PAUSE 0 BEFORE-HIDE.

MAIN-LOOP
FOR EACH customer
NO-LOCK:
READKEY PAUSE 0.
IF LASTKEY = 309 THEN
LEAVE MAIN-LOOP.
DISP customer.
END.
</pre>
 
Back
Top