>I would like to add a functionality wherein a user can "cancel" an ongoing process. Say im scanning a million records and doing some sort of calculations within that scan, depending on the speed and memory of the user's pc and the size of the data, the process takes quite a bit of time and it would be nice if the user have the option to "cancel" the process at any given time. There would be a cancel button on the form, and when pressed, stops the process at its tracks. The problem is that, i think, inside a scan-endscan, all other pending processes are attended to *AFTER* the scan ends. How can i do this in VFP?
First create a variable or a form property that is .T. then have a button that sets it to false. To allow VFP to respond to the user clicking, put a DOEVENTS in the SCAN loop
plStopLoop = .F.
USE TEST
SELECT TEST
SCAN FOR plStopLoop = .F.
DOEVENTS
WAIT WINDOW STR(test.something) NOWAIT
ENDSCAN
plStopLoop = .T.