>>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
>> llRet = .T.
>>ELSE
>> 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