>>if m.SomeMemVar
>> replace FieldX with m.Val1 ;
>> for some_other_expression ;
>> while [TableX.]Cust_ID = m.nCust_ID
>>endif
>
>I want to be able to stop the process.
>
>So, I have something like this
>ON ESCAPE plStop = messagebox('Are you sure you want to stop replace process?,36,'Stop process')=6
>
>So, user can hit ESC and the process would be stopped.
>
>That's the idea, and it similar to Sergey's SCAN solution, but SCAN is slower than one replace command.
>
>However, WHILE clause always makes the process to start from the current record, and I was not aware of it (or didn't realize it). So, in order to fix the problem my colleague put GO TOP at the top on the command button Click method. Unfortunately, there are multiple replaces under certain conditions, so this is still a partial solution...
Escape could fire only between commands - I don't think you can get it to fire during a replace. Besides, I wouldn't really rely on messagebox, it gets you out of the VFP event loop and executes somewhere outside of it (it's just a Windows service and gets its own window which seems to be not a child of VFP's window).
Did you really get this to fire? I remember that back in FoxPlus days I used to interrupt long replaces with escape, so maybe it still would. You may try with something natively fox, not messagebox - maybe
ON ESCAPE plStop =empty(inputbox("..."....))