Inheritance and Custom Properties

Dick Kriesel dick.kriesel at mail.com
Wed Apr 15 13:05:43 EDT 2009


On 4/15/09 4:58 AM, "David Bovill" <david.bovill at gmail.com> wrote:

> If you want them "inherited" you need to define a "getprop" handler.

You can inherit any custom property even without getprop handlers, by
walking through the object's long id until you find a value.

Here's a function that does that for any given custom property name, and
optionally any given custom property set name as well.

If you're interested in a similar function that identifies the object that
provided the effective value, let me know.

As usual, watch out for line wraps imposed by email.

-- Dick

<postScript>

function effectiveValue pCustomPropertyName,pCustomPropertySetName
  put long id of the target into tRevObject
  if pCustomPropertySetName is empty then
    put "put the" && pCustomPropertyName && "of tRevObject into tValue" into
tStatement
  else
    put "put the" && pCustomPropertySetName & "[" & quote &
pCustomPropertyName & quote & "] of tRevObject into tValue" into tStatement
  end if
  lock messages
  repeat until tRevObject is empty
    do tStatement
    if tValue is empty then
      if word 1 of tRevObject is "stack" then
        delete word 1 to 3 of tRevObject
      else
        delete word 1 to 4 of tRevObject
      end if
    else
      exit repeat
    end if
  end repeat
  unlock messages
  return tValue
end effectiveValue

</postScript>





More information about the use-livecode mailing list