Hi Mike,
if you need to cancel a loop, can't you use a button to set a flag and then use DOEVENTS to let VFP process button clicks? If you have to use the keyboard, another possibility would be to set a cancel flag in an ON KEY LABEL.
FWIW, your code works for me, after added some code for the ctr variable.
--
Christof