At 15:50 2017-05-10, Fred Taylor <fbtaylor(a)gmail.com> wrote:
>No, I think the called method, if it uses WITH/ENDWITH, it would be OK.
It will continue with the object reference chain if the called
method uses a WITH followed by a .-initial reference. I mean something like:
with anobject
with .subobj && a WITH like this.
If it is not a .-initial reference, it does not.
See my code following.
>WITH/ENDWITH seems to be stack oriented even across calling levels, but
>where you are in the stack may not be what you expect for anything outside
>of a defined WITH/ENDWITH in the called method.
Nope. It appears to respect the calling WITH block. See my
.zerolevelsdown() method which has no WITH block but respects the
caller's WITH block. (If it did not, an error would be thrown.)
[snip]
*** Start of Test Program ***
* tmpwith
* WITH Experimentation
* Last Modification: 2017-05-10
? "*** Execution begins."
? program()
close all
clear all
set talk off
*
local o, o2
o=createobject("called","Hello, world!")
o.subinst("Goodbye, cruel world!","I really mean it!")
o2=createobject("called","another world")
o2.subinst("totally different","just totally")
with o2
o.meprint()
o.zerolevelsdown()
o.oneleveldown()
o.twolevelsdown()
endwith
*
close all
clear all
? "*** Execution ends."
return
define class called as custom
subobj=.f.
thetext=.f.
o=.f.
procedure init
lparameters thetext
this.thetext=thetext
return .t.
endproc
procedure subinst
lparameters thetext1, thetext2
this.subobj=createobject("called",thetext1)
this.subobj.subobj=createobject("called",thetext2)
return
endproc
procedure meprint
? this.thetext
? this.subobj.thetext
? this.subobj.subobj.thetext
return
endproc
procedure zerolevelsdown
? .thetext
return
endproc
procedure oneleveldown
with .subobj
? .thetext
endwith
return
endproc
procedure twolevelsdown
with .subobj.subobj
? .thetext
endwith
return
endproc
enddefine
*** End of Test Program ***
Sincerely,
Gene Wirchenko