Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Escape a method
Message
From
11/05/2010 02:32:16
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
11/05/2010 02:14:04
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01464090
Message ID:
01464100
Views:
29
>>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?
>
>If it's procedural code you're interrupting, ON ESCAPE is one possibility. You could combine this with RETURN TO ( SomeProcedure - could even be macro'd ) - or set up your own ESCAPE handler. Both of them horribly break object encapsulation but potentially let you write a wrapper for the entire calculation call stack.
>
>However, if VFP spends a lot of time in SQL engine processing, I don't believe SQL commands respond to SET ESCAPE.
>
>Another more radical idea for a wrapper would be for your main program ("Main") to spawn a separate process ("Child") to run the calculations asynchronously. For normal calculations Main would allow Child to complete. However, if Main received a user interrupt, it could hard kill Child via WinAPI calls or similar. This would be messy, likely to leave temp files strewn around which you might have to clean up later.
>
>Cleaner would be for Main to set a flag in Child, which instructs Child to terminate itself. This would require mods to the calculations in Child to periodically check that flag.
>
>On a related note, it's possible to interrupt certain SQL commands using UDFs, something like this:
>
>SELECT ;
>  MyNormalColumns ;
>  , ... ;
>  , MyUDF( ) AS DummyColumn ;
>  FROM ...
>
>
>FUNCTION MyUDF
>
>IF SomeFlagSomewhere
>  * Your Radical Command Here, e.g.
>  QUIT
>
>ENDIF
>
>RETURN .T.
>
I will consider this.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Reply
Map
View

Click here to load this message in the networking platform