using arrays in custom properties

Ben Rubinstein benr_mc at cogapp.com
Mon Mar 10 05:50:05 EST 2003


I'm storing an array in a custom property of an object.  Storing and
retrieving items is fine.  But I'm having no luck wiping them.

Let's say that I've got a price list object, and I want to have a custom
property array linking 'specials' to their special prices.  One day fruit is
on special offer:

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

The next day, vegetables are on offer:

    put "5.50" into the specialPrices["Potatoes"] of btn "PriceChecker"
    put "5.99" into the specialPrices["Turnips"] of btn "PriceChecker"

Now if I inspect the custom property 'specialPrices', it has all four items
listed, when I really only wanted the most recent two.

I want a way that I can start afresh, without caring what went before.  If
specialPrices was a global variable, I can wipe out the array by doing:
    put empty into specialPrices

or even
    delete variable specialPrices

How can I do something similar in the case of a customProperty which is an
array?  If I tried 
    put empty into the specialPrices of btn "PriceChecker"

...I would just create a new item in the 'customKeys' array, with key
"specialPrices", value empty.  The "specialPrices" array would be unchanged.

If I tried
  delete variable the specialPrices of btn "PriceChecker"
  delete variable specialPrices of btn "PriceChecker"
  delete the specialPrices of btn "PriceChecker"

... I would (did!) get a syntax error.

If I know the keys of the specialPrices array, I could at least put empty
into each one, which is sub-optimal but still not too bad... but I haven't
even found the syntax for that.  It's not:
  put the keys of the specialPrices of btn "PriceChecker"

All help gratefully received!

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