Simple Arrays

Jim Ault jimaultwins at yahoo.com
Sun Jan 10 05:47:18 EST 2010


In addition to the good answers above:

In Rev, the arrays are 'associative arrays'
This means the keys are strings, not integers.
Also, there is no particular order to the keys, such as last-in

There is no auto-increment by specifying a blank key
     such as      put 12.35 into arrayVar[]

The character limit for a key is 255 chars.
To store arrays on disk use
     arrayEncode() to convert to a string

Custom properties are the same thing as arrays.
Their namespace (parent) can be any object in Rev.
The keys are the custom property names.
Each Rev object can have unlimited sets of keys.

Thus
set the custompropertyset of this card to "yr2009"
set the Jan[21] of this card to "payday"
set the Jan[22] of this card to "lunch meeting"

-- define arrays equal to the properties
put the Jan of this card into yr2009Jan
put the Feb of this card into yr2009Feb

set the custompropertyset of this card to "yr1999"
set the May of this card to yr1999May

Caution when accidentally using a reserved word as a custom property
Caution: failure of assigning or storing or getting array values does  
not produce an error.
There is no error if you try to use an element of an array that does  
not exist.

Hope this helps

Jim Ault
Las Vegas


On Jan 9, 2010, at 5:12 PM, Bob Sneidar wrote:

> Hi all.
>
> Apparently I am not getting arrays AT ALL. I would think that given:
>
> put "1" & comma & "A" & comma & "Green" & return into theData
> put "2" & comma & "B" & comma & "Blue" & return after theData
> put "3" & comma & "C" & comma & "Orange" & return after theData
> put "4" & comma & "D" & comma & "White" & return after theData
>
> which would get me:
> 1,A,Green
> 2,B,Blue
> 3,C,Orange
> 4,D,White
>
> I could then split by column (or by row I get confused) and get a  
> simple array where:
> theData[1,1] = "1"
> theData[1,2] = "A"
> theData[2,1] = "2"
> theData[4,3] = "White"
>
> And so forth. However, this is NOT the case! If it were, I could  
> issue a command:
>
> put transpose(theData) into myArray
>
> and:
> myArray[1,2] = 2
> myArray[1,3] = 3
>
> and so on. If I got the entire row (I think there's a function for  
> that) then I would have effectively gotten the column of the  
> original data. Seems reasonable eh?
>
> So can someone please explain to me why I cannot get a simple x,y  
> row,column grid-like array using these simple commands? Revolution  
> seems to think that the first column MUST be the key! I would LIKE  
> for revolution to simply create it's OWN numerical keys and let my  
> data be my data. Maybe in the future add an argument to the split  
> and combine commands to tell it whether or not I WANT Revolution to  
> treat my first column as the key?
>
> If arrays worked like I described above, it would be a simple matter  
> to get a single column of an array, just by transposing it and  
> getting an entire row, instead of writing complex repeat loops to  
> get a column of data. Am I missing something here?
>
> Thanks for any wisdom you can give. I can save some helpful souls  
> the trouble of responding by saying I am capable of making repeat  
> loops to accomplish this. I was just hoping that maybe I was missing  
> something and I can in fact do what I thought I could.
>
> Bob_______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

Jim Ault
Las Vegas






More information about the use-livecode mailing list