Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Exit an ongoing scan
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00597144
Message ID:
00597145
Views:
17
This message has been marked as the solution to the initial question of the thread.
>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
* scan loop
plStopLoop = .F.
USE TEST
SELECT TEST
SCAN FOR plStopLoop = .F.
	DOEVENTS 
	WAIT WINDOW STR(test.something) NOWAIT
ENDSCAN

* click event of a button that cancels the scan loop
plStopLoop = .T.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform