Your FOR EACH...ENDFOR creates and uses its own copy of the lo var, not the one from your Local declaration.
You have to transfer the object reference to a an actual memory variable like you have done in your second example and that is why it works.
Thats also why the lo variable continures to show a .f. in the locals window.
HTH,
>I lost something here.
>Why is it out of scope? The locals window still shows that it exists, just the wrong type(). I assume that means that it's still in scope.
>
>>You have gone out of scope in the FOR...ENDFOR in the first example without making a memory variable reference to the lo object being evaluated.
>>
>>
>>>I'm using VFP 7.0
>>>
>>>This doesn't work
>>>
>>>myForm.method()
>>> LOCAL lo, lc
>>> lc = WPARENT( THIS.NAME )
>>> FOR EACH lo IN _VFP.FORMS
>>> IF lo.NAME == lc
>>> EXIT
>>> ENDIF
>>> ENDFOR
>>> IF TYPE( 'lo.NAME' ) = 'C' ;
>>> AND lo.WINDOWSTATE = 1
>>> lo.WINDOWSTATE = 0
>>> ENDIF
>>>
>>>but this does
>>>
>>>myForm.method()
>>> LOCAL lo, lc, loParent
>>> lc = WPARENT( THIS.NAME )
>>> FOR EACH lo IN _VFP.FORMS
>>> IF lo.NAME == lc
>>> loParent = lo
>>> EXIT
>>> ENDIF
>>> ENDFOR
>>> IF TYPE( 'loParent.NAME' ) = 'C' ;
>>> AND loParent.WINDOWSTATE = 1
>>> loParent.WINDOWSTATE = 0
>>> ENDIF
>>>
Tom
Life happens, don't blink.