Example code : Multidimensional array 11x11 in SmartMS Model 3 - using auxiliar array
|
var
A1 : array of array of integer;
A2 : array of integer;
Begin
for var Index := 0 to 10 do begin
A2 := new Integer[0]; // important, so it's a different array
A1.Add(A2);
for var i := 0 to 10 do
A2.Add(Index + i);
end;
for var i := A1.Low to A1.High do begin
for var j := A1.Low to A1.High do
WriteLn(A1[i][j]);
end;
// for var Index := A2.Low to A2.High do
// WriteLn(A2[Index]);
|
|
Result is:
-----------------------------------------------------------------------------------------------------
0 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10 11
2 3 4 5 6 7 8 9 10 11 12
3 4 5 6 7 8 9 10 11 12 13
4 5 6 7 8 9 10 11 12 13 14
5 6 7 8 9 10 11 12 13 14 15
6 7 8 9 10 11 12 13 14 15 16
7 8 9 10 11 12 13 14 15 16 17
8 9 10 11 12 13 14 15 16 17 18
9 10 11 12 13 14 15 16 17 18 19
10 11 12 13 14 15 16 17 18 19 20
------------------------------------------------------------------------------------------------------
JS output:
var A1 = [];
var A2 = [];
var Index = 0;
var i$3 = 0;
var i$4 = 0;
var j$1 = 0;
for(Index = 0;Index<=10;Index++) {
A2 = [];
A1.push(A2);
for(i$3 = 0;i$3<=10;i$3++) {
A2.push(Index+i$3);
}
}
var $temp25;
for(i$4 = 0,$temp25 = A1.length;i$4<$temp25;i$4++) {
var $temp26;
for(j$1 = 0,$temp26 = A1.length;j$1<$temp26;j$1++) {
WriteLn($DIdxR($DIdxR(A1,i$4,""),j$1,""));
}
}
|
|