I couldn't pass a thread on arrays without sticking in my 2c [Big Grin]

My favourite way to use 2D (and higher) arrays is to make them "CSV's":

Pick a delimiter for each dimension, I often use CHR(255), CHR(254) and down and don't normally use more than three dimensions. Let's use comma (,) and semi colon ( [Wink]

Now make one long string var with these delimiters:

So, a 3x24 array containing this info:

code:
Member	Posts	Rank
LLigetfa 2076 3
MCA 2698 2
HowardBullock 618 12
Shawn 2803 1
sealeopard 848 11
kdyer 1083 7
BrianTX 354 18
NTDOC 1205 6
Radimus 948 9
jpols 1512 5
Lonkero 957 8
Bryce 1808 4
RichardHowarth 425 15
DrillSergeant 588 13
AlexH 385 16
bleonard 527 14
cj 923 10
awinkel 270 21
WillHetrick 211 25
JackLothian 338 19
kholm 306 20
masken 216 23
DDavidson 378 17

would look like this:

Member,Posts,Rank;LLigetfa,2076,3;MCA,2698,2;HowardBullock,618,12;Shawn,2803,1;sealeopard,848,11;kdyer,1083,7;BrianTX,354,18;NTDOC,1205,6;Radimus,948,9;jpols,1512,5;Lonkero,957,8;B ryce,1808,4;RichardHowarth,425,15;DrillSergeant,588,13;AlexH,385,16;bleonard,527,14;cj,923,10;awinkel,270,21;WillHetrick,211,25;JackLothian,338,19;kholm,306,20;masken,216,23;DDavid son,378,17

To extract info from this mess, we use the SPLIT() function:

$record=SPLIT(mess, ";")[0] returns the first RECORD which is Member,Posts,Rank

SPLIT($record, ",")[0] returns the first FIELD of the specified record, which is Member

We can combine these two functions like this:

$result=SPLIT(SPLIT(string, ";")[record number], ",")[field number]

You can wrap that in a UDF if you want to. I normally only use this method for READ ONLY arrays, like lookup tables etc. To write a change to the array is a little more complex:

To change cj's "rank" to 1 ( [Big Grin] ) you want to change field 2 in record 19 (both are zero based) you just SPLIT the string into an array, change the particular element and re-join the array. This is easier in VBS with it's JOIN function, but can be done in KiX very easily. I have a UDF in my scripting page called vbJOIN.UDF that does this [Smile]

code:
$aRecords=SPLIT($sString, ";")  ; split the string into records
$aFields=SPLIT($aRecords[19], ",") ; split required record(s) into fields
$aFields[2]=1 ; make change(s)
$sString="" ; clear string
for each $zField in $aRecords
$sString=$sString+$zField+";" ; join
next
$sString=substr($sString, 1, len($sString)-1) ; string that last record marker

again, you can put all that in a UDF.

This is not the best, fastest or cheapest way to work with arrays, but it will help you get a better understanding of them [Smile]

It is also handy for passing info between places that does not support arrays, like the window.showModalDialog method in DHTML etc...

cj