Inheritance and Custom Properties

David Bovill david.bovill at gmail.com
Tue Apr 21 06:38:55 EDT 2009


In general it's good not to use "do" for repeated actions because of its
speed. I've actually not done a speed test, but I'm pretty sure calling a
custom prop directly (see below) is much faster.

Also using message inheritance will be much faster than repeating manually
through all the controls in the hierarchy. This won't matter for one-offs -
but I use these techniques for geometry management and they need to be as
fast as possible (without sacrificing ease of scripting or maintenance).

2009/4/20 François Chaplais <francois.chaplais at mines-paristech.fr>

>
> Le 15 avr. 09 à 19:05, Dick Kriesel a écrit :
>
> <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>
>>
>>
> but you do use the "do" command...


Actually you don't need to use "do' dick. One of the great things about
custom properties is that you can do this:

put "test_Prop" into myCustomPropvar
> put the myCustomPropvar of btn 1
>

You can also do this with params:  so in Dicks case

put pCustomPropertySetName & "[" & quote & pCustomPropertyName & quote & "]
> into myCustomPropvar
> put the myCustomPropvar of tRevObject into tValue
>

There used to be a bug in which you had to be careful about spaces with the
param passed - not sure if it is still there - email me if you get problems
and I'll dig it out.



More information about the use-livecode mailing list