Keys of a custom property array

Richard Gaskin ambassador at fourthworld.com
Mon Mar 4 16:49:11 CST 2013


Monte Goulding wrote:
> On 05/03/2013, at 7:47 AM, Richard Gaskin wrote:
>
>> 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.
>
> I believe the problem is actually the ambiguity between a custom property and a custom property set when using multi-dimensional syntax.
>
> http://quality.runrev.com/show_bug.cgi?id=6912
>
> I know there's another bug in there that I had input on but I can't seem to find it....

Mark's notes there describe a future challenge for the parser, but don't 
address the current storage format of arrays in custom props.

Try this:

Set the value of a custom property to an array, and save that stack.

Write out a binfile containing that same array passed through arrayEncode.

Now read the encoded array file as binary, delete the first char (it 
will be 5, a flag noting it's an array), and read the stack file as 
binary and see if the encoded array data is in the stack data.

In my tests it is, suggesting that the format used for encoded arrays is 
the same format arrays are stored in when put into a custom property.

This makes sense, given that arrays are memory-location-specific hashes, 
so they'd need a generic way to store it in a custom prop, and they 
already came up with the arrayEncode function at roughly the same time 
as we were able to save arrays into props.

This also explains why accessing these "unnatural" arrays are measurably 
slower than storing an equivalent one-dimensional array as a property 
set, since the latter doesn't have the overhead of running through 
arrayDecode.

--
  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