>Can we have one universal approach? E.g. I don't want to put multiple checks in the form's code.
>
>I have a Distribution form. This form runs several processes, I want to be able to stop them in any time.
I undestand that this is desirable, but I don't think a universal solution (like "SET ESCAPE ON") is possible, or practical. For instance, different cleanup code might have to be run, depending on where the user interrupts.
You might try a universal solution, with SET ESCAPE, or with a timer.
In my own code, I use the not-so-universal solution of having a function, User_Interrupt(), that checks for a certain key being pressed. Then, a typical scan loop might look as follows:
local llInterrupted
scan
if User_Interrupt()
llInterrupted = .T.
exit
endif
endscan
if llInterrupted
...
endif
The function User_Interrupt itself is very simple; the main commands are a) inkey(), and b) clear typeahead.
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)