Yep, they are sure associative only, but they are very flexible. Ordering one takes one line of code to put the keys into a variable, and one line to order the variable itself. When your pulling key names, just pull from the variable.
Multi-dimensional arrays aren't much more work, so overall it is kind of a wash.
SparkOut wrote: ↑Mon Apr 13, 2020 10:27 pm
@bogs, in that case, tData is not an array.
My bad, I was pre-occupied with a few other things at the time I posted

However, it does give foosmaster another way to work without even using an array.
Since you can set the itemDelimiter to close to anything, you can treat variables like the one I posted just like an array, if you wanted. More to your questions point as it were, let us assume you had data you wanted to enter into an array that has to remain in the order it is entered, and it could not be easily sorted, like a list where the keys were:
purple
orange
apple
12
MyCar
If you had a list like that, and wanted to make sure that the order remained consistent forever as it is entered, you could simply put it into a variable, separating it and its value with almost anything (but don't use a comma, for the love of god!!) and set the itemDelim to that. For instance -
purple numToChar(30) the color of plums
orange numToChar(30) sunset at dawn
apple numToChar(30) a day
12 numToChar(30) miles to go
MyCar numToChar(30) is red
Actual code to illustrate:
Code: Select all
# to actually put this together, I would opt for a loop, but for this list
## I'll do it manually....
put "purple" & numToChar(30)& "the color of plums" into line 1 of tData
put "orange" & numToChar(30)& "sunset at dawn" into line 2 of tData
put "apple" & numToChar(30) & "a day" into line 3 of tData
put "12" & numToChar(30) & "miles to go" into line 4 of tData
put "MyCar" & numToChar(30) & "is red" into line 5 of tData
set the itemDelimiter to numToChar(30)
put tData & cr & cr & Item 1 of line 1 of tData & cr & item 1 of line 2 of tData & cr & item 1 of line 3 of tData & cr & item 1 of line 4 of tData & cr & "...etc"
Which outputs this -
raw variable -
purplethe color of plums
orangesunset at dawn
applea day
12miles to go
MyCaris red
putting the 1st item of each line...
purple
orange
apple
12
...etc
I'm sure you get the idea.