returning result from a function when the number of items in the result varies

Ken Ray kray at sonsothunder.com
Mon Sep 22 00:26:18 EDT 2008


> So the number of lines in the KEYS of myArray is not a good test to see if
> an array has data or even how many lines of data are in the array.

True. Here's some basic tests (-> means "returns"):

Is a Variable an Array?
------------------------------
Rev 2.x:
    the keys of <variable>
        --> If empty, <variable> is not an array
Rev 3.x:
    <variable> is an array
        --> "true" if it is, or "false" if it isn't


What are the elements of an array?
-----------------------------------------------
put the keys of <arrayVariable>
    -> return-delimited list of elements


How many elements are in the array?
-------------------------------------------------
put the number of lines of (the keys of <arrayVariable>)
    -> the number of elements


Does an element in an array have a value?
------------------------------------------------------
put <arrayVariable>[<key>] is not empty
    -> "true" if it has a value, "false" if it does not


Has an element in an array been defined yet?
------------------------------------------------------------
put <key> is among the lines of (the keys of <arrayVariable>)
    -> "true" if it has been defined, "false" if it has not been defined


HTH,

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/





More information about the use-livecode mailing list