Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Escape a method
Message
 
 
À
11/05/2010 02:14:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Divers
Thread ID:
01464090
Message ID:
01464099
Vues:
27
>>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.
>
ON ESCAPE does interrupt SQL, but you need to have SET TALK ON then to see a progressbar. This is for SQL in VFP, of course.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform