>>>Hi,
>>>
>>>following problem occurs to me:
>>>I have a method that controls the data generation for reports. This could be complex calculation. If the user selects the wrong range it could run for a while.
>>>The control is generic, controled by a table. The calculation methods are well tested and established, and there is a large number of it. The callstack of the calculation could be variable, the position of the generic control too.
>>>
>>>Now the user likes to stop the generation.
>>>
>>>Is there a chance to use ESC key and/or some button to stop the generation without changing the calculation methods?
>>>
>>>TIA
>>>
>>>Agnes
>>
>>
>>Agnes,
>>
>>One way to go is to use SET ESCAPE ON. However, as far as I can remember, this may interrupt queries and can interrupt your calculation at some point and leave your program or routine in an inconsistent state
>>
>>I have found this in one of my comments
>>
>>
>>
>>
>>The way I have done this - in a very cpu intensive class - is to check for user input every second or so
>>
>>Basically, you call a function every second. If there was user input, you set a flag
>>It's up to you to test for the flag and exit gracefully
>>
>>
>>if( !empty(inkey(.0001, 'H')) )
>> this.SearchEscaped = TRUE
>>
>>endif
>>
>>
>>At certain points you test for
>>
>>if ( m.this.SearchEscaped )
>> .... stop what you are doing
>>endif
>>
>>
>>
>>Advantages
>>- you control when to check for user input
>>- you control when and where to exit gracefully
>
>Finaly an ON ESCAPE could set some property too, so I would not need the timer.
>
>I fear customers inconvenience will not be high enough to pay this rework. So we put this back to its 10 year old tomb.
>
>(-.-)
>Agnes
It's not a timer, Agnes, timers don't fire when foxpro is very busy
It's something in the main loop that checks for user input every second (see Inkey())
ON ESCAPE may interrupt (and skip) an instruction
Gregory