arrays
Stephen Gorton
sgorton at usa.net
Mon Jan 9 06:48:51 EST 2006
yes you're right.
i have just completed my own version of the average function that can
move up and down my "array"
i keep forgetting tht we are talking about an associative array with
possible non-numerical "keys"
i am used to array[linenumber][itemnumber]
which seems more simple to me (for what i wanna do anyway)
thanks to all
s
Alex Tweedly wrote:
> Stephen Gorton wrote:
>
>> xavier,
>>
>> found the solution....
>>
>> put average(item 2 of line 20 to 30 of thearray) into theaverage
>>
>> it scares me that i find the solution on google but not in the
>> documentation
>>
>> to be honest - rev is very powerful - but its difficult to harness
>> this power if it isn't documented, (ie 3rdparty books)
>> references are fine if you know the -exact- keywords that you are
>> looking for.
>>
> Hold on just a second there Stephen :-)
>
> I think there was some confusion there ... in Rev, it's common to hold
> a number of values in a single variable, each on a separate line. Many
> constructs that would require an array in other languages can be best
> handled that way. It sounds as though that's what you're doing - and
> in that case "average(item 2 of line 20 to 30 of thearray)" is indeed
> the answer.
>
> However, that is not what Rev calls an array.
>
> In Rev an *array* is a set of cell elements, each has a content and an
> index; they can be referred to as
> tArray[index]
> so you might say
> put 213 into tArray[index]
>
> I'd suggest it's misleading and potentially confusing to call a
> variable "thearray" if it is, in fact, a standard Rev variable holding
> its contents as a series of line-separated values.
> If you go have one of those Rev arrays, then you can get the list of
> all index values (as Mr X. said) by doing
> put the keys of tArray into theKeys
>
> You may also want to see the docs on "combine" and "split" which
> provide handy ways to convert from the array form to the "list of
> values on lines" form if you need to do so.
>
> P.S. you're right about it being hard to use the docs until you know
> the exact right words to look up. But there aren't that many of them,
> you'll learn the ones you need fairly quickly - so hang in there. And
> this mailing list will be here to help if you get stuck ...
>
>
More information about the use-livecode
mailing list