Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I set up a cancel button to cleanly cancel a proc
Message
From
26/01/2000 14:54:27
Tyson Bonn
Myers and Stauffer Consulting
Harrisburg, Pennsylvania, United States
 
 
To
23/01/2000 22:04:19
Robert Younis
V-Fox Programming & Consulting, Inc.
Miami, Florida, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00321518
Message ID:
00323064
Views:
28
The way that I have used in the past is VIA DoEvents and an abort flag. Before your process loop begins set the abort flag off. Then while the process is running, check to see if the abort flag was turned on. Your cancel button can then turn the abort flag on. Now, in order for all of this to work, your going to need to call DoEvents periodically to allow the cancel button to be clicked.

For example, in your start button you would have code similar to this:
Procedure Start.Click()

    This.l_Abort = .F.
    Select MyTable
    Scan While Not This.l_Abort

        *-- Allow for event processing (every 100 records).
        If RecNo() % 100 Then
            DoEvents()
        EndIf

        *** Any other code.

    EndScan

EndProc
And your stop button code would be something like this:
Procedure Stop.Click()

    This.l_Abort = .T.

EndProc
I hope this helps.
Tyson Bonn
Previous
Reply
Map
View

Click here to load this message in the networking platform