Recursion warning: what's the owner of a background?

Jonathan Lynch jonathandlynch at gmail.com
Thu Dec 23 10:07:07 EST 2010


This might or might not relate - but, in case it helps...

You can get the long name of an object...
Then replace " of " with "|" or any other character you want to use as an
item delimiter
Then you can count the number of  items, or use the first word of each item
to determine the type of object (group or card) that owns a given control.

On Thu, Dec 23, 2010 at 9:59 AM, David Bovill <david at vaudevillecourt.tv>wrote:

> Peter, not shure if I got you right?  Why not take:
>
> word 1 to 3 of the long id of theObjectRef
>
> In my case I need to check each level of the inheritance... if forgot that
> using "pass" would get the same result in some cases (in mine I want to be
> able to define getprop handlers anywhere in the hierarchy to override
> default behavior).
>
>
> On 23 December 2010 12:54, Peter Brigham MD <pmbrig at gmail.com> wrote:
>
> > On Dec 23, 2010, at 6:34 AM, David Bovill wrote:
> >
> >  This one just caught me out. I have a script that checks a property of
> >> it's
> >> owner and returns the value. Specifically it checks the owner for a
> >> property
> >> of the same name to see when the local value is empty to see if it is
> >> defined higher up in the object hierarchy. I thought this would be a
> safe
> >> way of implementing object oriented stuff.
> >>
> >> But you get recursion when the control is a background, because the
> owner
> >> of
> >> a background is the card the background is on, but the card is actually
> >> below the background in the message hierarchy, so the background script
> >> gets
> >> triggered again when you look for it in the backgrounds owner.
> >>
> >> A recursive tongue twister maybe - but just remember a background's
> owner
> >> is
> >> itself in scripting terms!
> >>
> >
> > On the other hand, this utility function works fine for me:
> >
> > function masterBG theObjectRef
> >   put the long id of the owner of theObjectRef into onr
> >   if word 1 of onr = "card" then
> >      return theObjectRef
> >   else
> >      return masterBG(onr)
> >   end if
> > end masterBG
> >
> > It returns the highest level group a control belongs to. I have a stack
> > with two major backgrounds (switch between making one or the other
> visible
> > with a button). In my custom find function I need to know which master
> > background the foundfield is part of, and it may be nested in lower level
> > groups, so this tells me which bg to show when a string is found, and it
> > works reliably without the recursion problem above.
> >
> > -- Peter
> >
> > Peter M. Brigham
> > pmbrig at gmail.com
> > http://home.comcast.net/~pmbrig <http://home.comcast.net/%7Epmbrig>
> >
> >
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
Do all things with love



More information about the use-livecode mailing list