Inheritance and Custom Properties

Jim Bufalini jim at
Wed Apr 15 07:11:10 EDT 2009

Hi Richmond,

> Yup, it's Richmond, 2-3 years behind the times :)
> Well, to be honest, I've never really had the need of custom properties
> before.
> Reading the EXCELLENT RevolutionUsersGuide.pdf (and, by EXCELLENT, I
> mean
> far better in many respects than the online Documentation) I find that
> whether a property is inherited or not depends on mysterious decisions
> taken 'on high', err, well, Edinburgh; or, decisions taken along time
> ago by the oft-reviled Scott Rossi in MetaCard days.
> --------------------------------------------------------------------
> I know that heritable properties can be over-ridden;
> What is unclear to me is if properties that are not normally inherited
> can be set to be inherited.
> --------------------------------------------------------------------
> Now, I have started to learn about custom properties, not through any
> real need for them, as all I need for the goofy content delivery
> programs
> for my school I already know, but for intellectual stimulus (a bit
> short
> of that teaching kids EFL).
> So, I set up a stack with a card called 'WUN' and
> a button called 'CusProp';
> and typed this into the Message box:
>  set the porkNbeans of btn "CusProp" to 547
> all very straightforward; and when I open the properties editor I can
> see
> the custom property 'porkNbeans' quite clearly.
> Decided to be clever and typed this into the Message box:
> set the custardTart of card "WUN" to 99
> same as the button: worked like a charm.
> The made a field. and put this in the button 'CusProp':
> on mouseUp
>   put "the porkNbeans of btn" && quote & "CusProp" & quote && "is" &&
> the porkNbeans of me into line 1 of fld "Props"
>   put "the custardTart of btn" && quote & "CusProp" & quote && "is" &&
> the custardTart of me into line 2 of fld "Props"
>   put " " into line 3 of fld "Props"
>   put "the custardTart of card" && quote & "WUN" & quote && "is" && the
> custardTart of card "WUN" into line 4 of fld "Props"
> end mouseUp
> and found that 'custardTart' of btn 'CusProp' is empty
> (meaning it does not have a custom property 'custardTart')
> so learnt that custom properties are not inherited (or, at least not
> 'custardTart').

This is correct. Think of custom properties as arrays where the custom property set is the array variable. The custom property is the key. And the key has a value. So using your example (except I changed the name of the button to btnCustProp, so as not to be confusing) and I added custom property sets. And you use array syntax. So put this in you button:

ON mouseUp pMouseBtnNo
    set the myCustPropSet["porkNbeans"] of me to 547
    set the myCustPropSet["custartTart"] of me to 99
    set the myCustPropSet["custartTart"] of cd "WUN" to 100
    put (the myCustPropSet["porkNbeans"] of btn "btnCustProp" = the myCustPropSet["porkNbeans"] of me) into line 1 of fld "Props"
    put (the myCustPropSet["custartTart"] of btn "btnCustProp" = the myCustPropSet["custartTart"] of me) into line 2 of fld "Props"
    put (the myCustPropSet["custartTart"] of cd "WUN" = the myCustPropSet["custartTart"] of the owner of me) into line 4 of fld "Props"
END mouseUp

This will set lines 1, 2 and 4 to true in your field. As to inheritance, no (as far as I know) and I don't think you would want it. ;-) 

To reference a custom property, you must use a fully qualified path. So the above creates two separate custom property sets by the same name of myCustPropSet. One in the card and the other in the button. The card one has one custom property (key) and the button has two custom properties (keys).  Because they are not inherited, you are able to set them all independently to different values, even though they all have the same names and keys.

Aloha from Hawaii,

Jim Bufalini

More information about the use-livecode mailing list