Does 'exists' work on arrays?
livfoss at mac.com
Sun Mar 15 18:04:26 EDT 2015
That looks just like my box model to me - very gratifying! It may possibly show that I’m getting the hang of it at last.
Thanks for the correction on the idea of an object - I see now that it has to be a control, something that is capable of being displayed: so not a variable, array, script etc.
> On 15 Mar 2015, at 21:20, J. Landman Gay <jacque at hyperactivesw.com> wrote:
> On 3/15/2015 11:50 AM, Graham Samuel wrote:
>> Still struggling with arrays: no results, no error messages, no data… will get there no doubt. While trying to get there, I tried
>> put exists(myArray[“gpx”])
>> I got ‘false’, but the IDE seems to say that the top key in this multidimensional array is “gpx”, so why isn’t it true?
> "Exists" is only for card controls. Array elements are variables, so myArray(["gpx"]) resolves to the content of whatever is stored inside the gpx variable.
> If you want to know whether there's a key named "gpx" then:
> put "gpx" is among the lines of the keys of myArray
> If you want to know the content of the key named "gpx":
> put myArray["gpx"]
> Devin had a cool way to explain arrays in one of our classes some years ago. He just held up an egg carton. That's an array. Each egg depression holds some kind of egg (a variable.) The egg carton can be big enough that each egg depression holds a whole different egg carton.
> carton = the egg in the first slot
> carton = the egg in the third slot of the carton that's in slot 1 of the main carton
> The slots can be named instead of numbered. The names identify the slots, not the contents:
> carton["gooseEggs"] = the value of whatever is in the slot named "gooseEggs" in the main carton
> carton["gooseEggs"]["Canadian"] = the value in the slot named "Canadian" of the carton that's named "gooseEggs" which is inside the main carton
> And yeah, it gets confusing when the arrays get big.
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode