Keys of a custom property array

Richard Gaskin ambassador at fourthworld.com
Mon Mar 4 14:47:55 CST 2013


Peter Haworth wrote:
> Richard,
> I think your explanation of how arrays stored in cprops are translated back
> and forth between internal and external storage explains the the
> performance differences in Mark's tests.
>
> I am curious though about your comment on storing multi-dimensional arrays
> in cProps.  Are you saying it's not possible to store multi-dimensaional
> arrays in cProps?  I was hoping to do that in a project I'm about to start
> on.

Objects natively support one-level deep arrays of custom properties, 
with which we can use array notation to access, e.g.:

    get the PropSetName["SomeKey"] of btn 1

If you want to store an array as the value of a custom property, I 
believe that the array is stored in the same format you'd get if you ran 
the array through arrayEncode.

This hasn't been confirmed by RunRev, or even rigorously tested here, 
but would reasonably explain why we can't use array syntax to access 
anything deeper than the "natural" one-level deep properties.

And if memory serves, the ability to store arrays as property values was 
introduced in the same version in which arrayEncode and arrayDecode 
premiered, seemingly reinforcing this hypothesis.

So yes, you can store arrays of any depth in property values going back 
many versions, but to use that data you'll have to put the prop value 
into a variable and access it from there, as you won't be able to access 
individual elements of the array when stored as a property.

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys



More information about the use-livecode mailing list