>Hi!
>
>Put in the loop the DOEVENTS command. This will force firing of all events, include button clicks and ON KEY commands. ON KEY commands will interrupt the program without DOEVENTS only if _VFP.AutoYield = .T., that is why you get it work not always. Though I recommend to show a "Cancel" button on the form during the process and use DOEVENTS in the loop, so user can press on the Cancel button to interrupt the long process.
Vlad, I find it great that you are back on the forum.
This is great information for me: I didn't know it was at all possible to react to button clicks (for Cancelling) while doing a long operation. I just tried it, and it worked great. Previously, I used inkey(), and told users to use a certain key if they wanted to interrupt the process.
However, I did notice in my tests that DoEvents takes quite a while. Therefore, for tight loops, it might be useful to do something like this (supposing you process records):
if recno() % 100 = 0
DoEvents
endif
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)