I am experimenting with Alerts, studied the documentation and the posts that I find on ClarionHub. I’m using CW6.3 ABC. I’ve been trying things but still missing something.
Nothing happens when I press the Esc key nor does the test message at the Window Event AlertKey get triggered. I’m trying to provide an Esc to break out of a Routine. See the code snippet in the image.
This isn’t critical to me but rather something I would like to be able to implement as it may be useful in my multi-dll veterinary app. Learning something new is always good.
Thank you for any guidance. Regards to all.
Doug Selzler
You are in a “tight loop”, there’s no chance for your code to receive an event.
To be responsive to events, you need to let the program flow get back to the ACCEPT statement.
So you’ll need to break your process into parts where you intialize everything and then do a small amount of work
maybe just one time through the loop,
or pay attention to clock
and break out of the loop when you’ve hit a fixed amount of time
for example 0.1 seconds
Once you’ve broken out of the loop, if there is more work to be done then POST(EVENT:User). When you receive EVENT:User you do some more work
This gives your user the chance to press ESC and the code will have a chance to see that and respond.
I dimly recall that there is a process template which helps you do all of this
Sorry I’m an hand coder - I don’t use templates so it’s hard to remember what they do
I played with each of the suggestions and have decided “tight loops” are best avoided. The software has been around for decades and some long time users have accumulated hundreds of thousands of records over that time. When running reports or analysis with large date ranges, I have presented a warning message to the user advising they use a shorter interval .
But I have learned, over many years, that no matter how clearly I may word a message and offer alternatives that messages are seldomly read. Well too bad I guess. I don’t generally advise “ending the task” but some users know that is available.
Always trying to make the software friendlier. Still having fun. Thanks again for a wonderful resource.
I looked in my progress class, which I use in places where I have a tight loop.
I use the KEYBOARD ASK approach. .
If I were to pull out the code and put it in a loop, it would look like this.
abort=false
LOOP
If KEYBOARD()
Ask()
If Inlist(KEYCODE(),PauseKey,SpaceKey,EscKey)
If Message('Do you want abort process?','???',Icon:Hand,Button:Yes+Button:NO)=Button:Yes
abort=true
END
END
END
if abort
BREAK
END
!stuff to do
End