Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Issues with on escape & retry
Message
De
25/03/2009 13:10:21
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 2000 SP3
Divers
Thread ID:
01387783
Message ID:
01391440
Vues:
68
>>Try modifying your code to this;
>>
>>
>>Function EscapeKey
>>LOCAL lnOldArea, lnRetval, llRet
>>lnRetval = Messagebox("Are you sure you want to cancel?",32+3, "Escape pressed")
>>
>>IF lnRetval = 6 && Yes
>>   llRet = .T.
>>ELSE && No
>>   llRet = .F.
>>ENDIF
>>RETURN llRet
>>
>>
>>First I am moving the return to outside of the IF statement and second I have removed the RETRY which really only is usefull in an error handler.
>
>Or even this! <g> ---
>
>
>Function EscapeKey
>#INCLUDE foxpro.h
>LOCAL lnRetval
>
>lnRetval = Messagebox("Are you sure you want to cancel?", MB_YESNOCANCEL+MB_ICONQUESTION, "Escape pressed")
>
>RETURN (lnRetVal = IDYES)
>
Hi All,

Thanks for the responses.

Maybe i mis-understood the usage of retry.
Imagine this scenario:
a loop is running which performs 10 long running queries.
When user presses Esc, it will cancel one of the queries mid-run, therefore no results are produced for that query.

If I return from the EscapeKey function, won't it skip to the next record in the loop, therefore my result set will only have 9 queries instead of 10?

From the VFP Help:
However, if a procedure specified with ON ESCAPE includes RETRY, the program line that was executing when you pressed ESC executes again

In practice, when I tested my above theory, this was not the case.. but it did seem logical to me.

As for Jims "single exit point" coding, I agree this is a best practice which should be used.
Will Jones
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform