At 15:50 2017-05-10, Fred Taylor <[email protected]> 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


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/886ff2eff4cc7b0e7adb7a2ba21fb51b@mtlp000085
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to