using arrays in custom properties

Jeanne A. E. DeVoto jeanne at runrev.com
Thu Mar 13 03:40:09 EST 2003


At 9:16 AM -0800 3/11/03, Ben Rubinstein wrote:
>> I'm storing an array in a custom property of an object.
[...]
>So, I'm now coming to see - or at least believe in - a different model.
>JEANNE OR SOMEONE PLEASE CORRECT ME IF I'M STILL IN ERROR!  What I now
>believe is something like this:
>
> a) objects can have named arrays associated with them.  These arrays
>    are known as 'custom property sets'.  They are accessed using the syntax
>        set the abc[k] of object x to y
>
> b) one of these arrays can be set as the default, for which there is a
>    special syntax, in which you don't need to specify the name of the
>    array, Such that (if the 'abc' array is set as the default)
>        set the k of object x to y
>
>    is equivalent to
>        set the abc["k"] of object x to y


That's one way to think of it, and certainly isn't incorrect.

Another way that might be somewhat clearer is this:

1. Objects can have custom properties associated with them. These custom
properties cannot be arrays - only scalar values.

2. Custom properties can be grouped into custom property sets.

3. You can refer to a custom property in any custom property set using
array notation, so for practical purposes, you can think of a custom
property set as an array.

I beefed up the custom properties article in the encyclopedia recently -
here's what I wrote about this:
----
Using array notation with custom properties
All the custom properties in a custom property set form an array. The
array's name is the custom property set name, and the elements of the array
are the individual custom properties in that custom property set.

Using array notation, you can refer to custom properties that aren't in the
current custom property set, without changing the object's
customPropertySet property. For example, suppose a button has a custom
property named "myProp" which is in a custom property set called "mySet".
To refer to this custom property regardless of which custom property set is
active, use a statement like one of the following:

  get the mySet["myProp"] of button 1
  set the mySet["myProp"] of the target to 20
----

The important fact, I think, is that when you say

  put "23.99" into the specialPrices["Bananas"] of btn "PriceChecker"

you're actually creating a custom property set, with the custom property
"Bananas".

--
Jeanne A. E. DeVoto ~ jeanne at runrev.com
Runtime Revolution Limited - The Solution for Software Development
http://www.runrev.com/





More information about the use-livecode mailing list