Page 1 of 1

Array index - getting element by a number or string

Posted: Thu Mar 04, 2010 8:02 pm
by heyvern
I think I know the answer but I just would like confirmation. It is clear that you can't access an array value numerically if it is indexed with a string. However In the documentation it says there is a way to access "elements" in the array by looping or repeating using the key word "element".

I have an array that is indexed by strings:

Code: Select all

theArray["head]["static_values"]
theArray["head]["styles"]
theArray["head]["animated_values"]
This doesn't work:

Code: Select all

put element 2 of theArray["heads"]
I just want to make sure it isn't possible to access array elements numerically in any way at all before I go with the numbered index... numbers are probably better anyway.

Re: Array index - getting element by a number or string

Posted: Thu Mar 04, 2010 8:28 pm
by FourthWorld
All arrays in Rev currently are associative arrays, using name-value pairs.

So you could use:

put theArray["head"]["styles"]

...but there is no integer associated with an array element unless you use integers as your keys:

theArray["head"][1]
theArray["head"][2]
theArray["head"][3]