Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Processing Data, Displaying Messages and a Cancel Button
Message
From
14/10/1999 17:37:02
Kenneth Downs
Secure Data Software, Inc.
New York, United States
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00276528
Message ID:
00276585
Views:
30
Cathy,

Bravo, a woman after my own heart. I once did something like this for my own sake during debugging, and the customer, much to my surprise, flipped. They loved it.

I did it this way:
1. Launch a form with a listbox (or put the listbox and finalizing code in the current form)
2. As you process, put messages in the cursor, updated in the listbox. One nice trick is to be able to print out the log afterward. Also nice are elapsed time, and generally any kind of tidbits they might conceivably want to know.
3. At various stages in the processing code, execute a "DoEvents" command, which makes your form responsive to the user, so they can click on the [CANCEL] button.
4. The cancel button should set a form property which you are checking periodically throughout the process. If the user has

All of this chews up cycles, but not many, and the user response to the display and control more than makes up for any slowdowns.

Here is a trick that slows down a COPY TO a little bit, but allows the user complete control.
LOCAL IWillCauseAnError  &&--declared but not initialized
LOCAL lnError
lnError = 0
ON ERROR lnError = -1
COPY .... FOR IIF(NOT MyCancelFlag,.t.,EVAL(IWilLCauseAnError))
IF lnError = -1
  * 
  *  hey, the user cancelled, do something
  *
ENDIF
I've never tried it with a SQL Select, but it ought to work, though it may need some tweaking.

One problem with the above is that the form does not respond, so you need to put a DoEvents into it. But if you do that, the things slows to an absolute crawl, so you can do something like:
COPY .... FOR IIF(MOD(RECNO(),1000)=0,MyDoEvents(),.t.)

PROCEDURE MyDoEvents
*
*  The KEYBOARD stuffing causes the DoEvents to do its job
*  without pausing 1/4 second, it is more nearly instantaneous
*
KeyBoard {ALT+F}  &&--some keystroke known to be meaningless
DoEvents
RETURN .t.

Hope this helps.
>I have a form where the user enters a Job Number that needs to be finalized. After they've entered the Job Number and pressed the "Finalize" button, the following is what I want to happen -- I'm just not sure how to approach this.
>
>As I process the data, I will be writing warning and error messages to a cursor. I want these to appear on the form as well, maybe in a grid or something, as the processing is occurring. I want the user to be able to scroll thru this grid (or whatever) while the processing continues so they can monitor the progress without
>interferring with it. I also want the user to be able to press a "Cancel" button at any time to stop the processing.
>
>How would I approach this?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform