Split and combine only work on the last level of keys in an array, and
they are a little too unwieldy for me, although I use them frequently
for two-dimensional arrays and custom properties.
I prefer the following:
--there is no array named kitchen yet
put "bacon" into kitchen[refrigerator][drawer][top]
-- now there is an array with one value and 3 keys
put "cheese" into kitchen[refrigerator][drawer][top]
--replaces bacon
--assuming 3 trays in the door
put "eggs" into kitchen[refrigerator][door][shelf][top][tray][1]
put "garlic" into kitchen[refrigerator][door][shelf][top][tray][2]
put "coffee" into kitchen[refrigerator][door][shelf][top][tray][3]
-- let's put part of the data into another array temporarily
put kitchen[refrigerator][door][shelf][top][tray] into foodArr
foodArr is two-dimensional and has 3 keys
[1] eggs
[2] garlic
[3] coffee
put "butter" into foodArr[2]
put "horseradish" into foodArr[3]
foodArr is two-dimensional and has 3 keys
[1] eggs
[2] butter
[3] horseradish
--now let's define a new array and put it into the big one
put empty into foodArr
put "meat" into foodArr[1]
put "lettuce" into foodArr[2]
put "milk" into foodArr[6]
put "cream" into foodArr[jar in the door]
--now let's put the new data into the big array
put foodArr into kitchen[refrigerator][door][shelf][top]
--this means that [tray] is gone
-- replace by 4 keys 1 2 6 "jar in the door"
All the keys in a particular dimension have to be unique.
Reusing the key means you are replacing that key's current definition
Unless you really want to study multidimensional arrays and learn the
code tricks, be prepared for a mind bender as you attempt to debug
your code, then wonder if you could ever trust it, let alone come back
next year and modify it for version 2.16a
Fun, games, and then some.
Jim Ault
Las Vegas
On Jan 10, 2010, at 5:52 AM, Thomas McGrath III wrote:
Pardon my question, but I have learned more about arrays in these
four posts than I ever thought about before:
So given that I would want a multi-dimensional array where theData[2]
[3] = "Blue" as in the examples provided, what is the 'best' way to
enter data into this array, or is the way Bob did it the best way?
Workflow:
First;
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
Then ;
split theData with cr
Would this get me theData[2][3] = "Blue" ??? I thought the delimiter
was TAB?
Would this be better:
put "1"& tab& "A"& tab& "Green"& return into theData
OR is this all wrong and if so what is the 'best' way to enter a lot
data into a mutli-dimensional array to get these results??
Thank you for this.
Tom McGrath III
Lazy River Software
[email protected]
iTunes Library Suite - libITS
Information and download can be found on this page:
http://www.lazyriversoftware.com/RevOne.html
On Jan 9, 2010, at 9:37 PM, Phil Davis wrote:
Hi Bob,
On 1/9/10 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
Actually either of these:
split theData with cr
split theData by row -- where the rowDelimiter is CR
would get you this:
theData[1] = "1,A,Green"
theData[2] = "2,B,Blue"
theData[3] = "3,C,Orange"
theData[4] = "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!
Right. Technically speaking, comma is not an array index separator.
Commas in our array keys help us conceptually represent multiple
array dimensions in our own minds, but Rev sees an array with such
keys as a simple one-dimensional array with alphabetic keys (since
commas are not numerals).
Until version 3.0, Rev couldn't handle true multi-dimensional
arrays. Since then, the thing that tells Rev "this is a multi-
dimensional array" is multiple keys per element, with each key in
its own bracket. Like this:
theData[1][1] = "1"
theData[1][2] = "A"
theData[1][3] = "Green"
Now do you see why 'transpose()' wouldn't work with your array? In
part it's because your keys aren't numeric - they contain commas.
(Also they have to be sequential numbers.)
Welcome to array re-education camp! ;-)
Phil Davis
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
[email protected]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
Phil Davis
PDS Labs
Professional Software Development
http://pdslabs.net
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Jim Ault
Las Vegas
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution