>>>Hi everybody,
>>>
>>>I recall there were some issues of using return statements within with /endwith blocks. Can you point me out to some related blogs and is it still considered a bad practice to use them?
>>>
>>>Can they lead to VFP9 crashes (especially since there is ActiveX involved)?
>>
>>Personally witnessed a returning local var changing datatype in calling function when issued from within with..endwith.
>>Uncertain if it was with vfp6 or vfp8 libs.
>>After that having only single return statement was given higher priority and a simple code scanner to find returns inside with was written, run directly after next release with manual fixes.
>
>Maybe related to this:
http://fox.wikis.com/wc.dll?Wiki~WithLeaksLocals ?
I'd agree with both Steven and Sergey on this one - this is by design, and the scope of with-endwith applies to a temp private variable that holds reference to the with-endwithed object. Or else with-endwith wouldn't be as useful as it is.
I know I've used this in several methods which are intended to be called from inside a with-endwith block, i.e. they contain a lot of .ref things without the corresponding with/endwith lines, which are left to the caller. Yes, a reference could be passed as a parameter but AFAIR I had some valid reasons for doing so. And it still works flawlessly.