using arrays in custom properties
Ben Rubinstein
benr_mc at cogapp.com
Tue Mar 11 12:20:01 EST 2003
on 11/3/03 12:22 am, David Epstein wrote
> The first comments on this question puzzled me, as they involved setting
> custom property SETS, whereas the question seems only to deal with custom
> properties themselves.
I think this reflected on a confusion I had. My understanding was that one
could think of custom properties in three steps (let's say, one could learn
about them by three observations):
a) objects can have custom properties:
set the abc of object x to y
b) these custom properties can be arrays, in which case the syntax is
set the abc[k] of object x to y
c) custom properties can be grouped in sets, allowing one for example
to have one set of custom properties for the English version of an
app, another for the French version.
I didn't really care about the last of these three observations. As far as
I was concerned, my question related to the second; I had no interest in
custom property sets, I was just interested in custom properties which
happened to be arrays. I said:
> I'm storing an array in a custom property of an object.
Like you, my first reaction to the initial responses was that they had got
the wrong end of the stick. But before I wrote back saying 'thanks very
much, but this isn't what I'm asking' I actually tried some of the
suggestions, and realised it worked...
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
(note the quotes!)
c) ...and then there are some minor details, as follows:
- some extra syntax: the 'customKeys' property returns the keys of the
current 'default' array. Setting the 'customKeys' deletes or creates
keys accordingly - newly created keys have empty values.
- one of these arrays, initially the 'default' array, has no name. You
can only access this array when it is the default array, using the
secondary syntax noted above.
- some extra syntax: the 'customPropertySet' property is the mechanism
for selecting which array is to be the 'default' array (where empty
refers to the 'set with no name').
- some extra syntax: the 'customPropertySets' is a property which
returns the list of arrays (not counting the one with no name); and
which allows you to effectively delete one or more of the existing
arrays.
In other words, rather than there being two things (custom properties, and
custom property sets); or even three things (simple custom properties, array
custom properties, and custom property sets); there is only thing: custom
property sets, which are arrays.
I don't know if this model is exactly right. It certainly seems to
correspond better with the observed behaviour, and gives me a better basis
for predicting the effect of different code, than the one I had before.
I'd be interested in comments from those more experienced in these
matters...!
Ben Rubinstein | Email: benr_mc at cogapp.com
Cognitive Applications Ltd | Phone: +44 (0)1273-821600
http://www.cogapp.com | Fax : +44 (0)1273-728866
More information about the use-livecode
mailing list