inheriting any custom property

Dick Kriesel dick.kriesel at mail.com
Sat Sep 24 16:33:34 EDT 2005


On 9/24/05 12:18 PM, "Dan Shafer" <revdan at danshafer.com> wrote:

> I like this a lot. I've added it to my Scripter's Scrapbook and will
> find frequent use for it, I'm sure.

I had you in mind when I posted it, Dan.  I looked for something about
inheriting properties in your articles about Rev and OOP; maybe this will
serve in some future edition of an article or eBook.

Anyway, after I posted it, I recognized it ignored custom property sets.
So, here's a new, improved version that respects an optional custom property
set:

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

The example application I posted before is still valid:

getProp uSampleProperty
  return effectiveValue(param(0))
end uSampleProperty

And here's a new example involving a custom property set:

getProp uSamplePropertySet[uSampleProperty]
  return effectiveValue(param(1),param(0))
end uSampleProperty

-- Dick





More information about the use-livecode mailing list