2indianz
_temp set [_y, _temp]; // this code creates circular reference
some example:
matrix = [
["a1", "a2", "a3", "a4"],
["b1", "b2", "<>", "b4"],
["c1", "c2", "c3", "c4"],
["d1", "d2", "d3", "d4"]
];
matrix select 1 set [2, "B3"]
matrix = [
[
["1.a1", "1.a2", "1.a3", "1.a4"],
["1.b1", "1.b2", "< >", "1.b4"],
["1.c1", "1.c2", "1.c3", "1.c4"],
["1.d1", "1.d2", "1.d3", "1.d4"]
],
[
["2.a1", "2.a2", "2.a3", "2.a4"],
["2.b1", "2.b2", "2.b3", "2.b4"],
["2.c1", "< >", "2.c3", "2.c4"],
["2.d1", "2.d2", "2.d3", "2.d4"]
],
[
["3.a1", "3.a2", "3.a3", "3.a4"],
["3.b1", "3.b2", "3.b3", "3.b4"],
["3.c1", "3.c2", "3.c3", "----"],
["3.d1", "3.d2", "3.d3", "3.d4"]
],
[
["4.a1", "4.a2", "4.a3", "4.a4"],
["4.b1", "4.b2", "4.b3", "4.b4"],
["4.c1", "4.c2", "4.c3", "4.c4"],
["< >", "4.d2", "4.d3", "4.d4"]
]
];
matrix select 0 select 1 set [2, "1.B3"];
matrix select 1 select 2 set [1, "2.C2"];
matrix select 2 select 2 set [3, "3.C4"];
matrix select 3 select 3 set [0, "4.D1"];
_row = matrix select 3 select 3;
for "_i" from 0 to count _row -1 do {
_row set [_i, toUpper (_row select _i)]
};
matrix call compile preprocessFileLineNumbers "showArray.sqf"
for debugging use this function:
// showArray.sqf
private ["_result", "_indents", "_depth", "_0D0A", "_getIndent", "_writeLine", "_unwrapTree"];
_result = "";
_indents = [""];
_depth = 0;
_0D0A = toString [13,10];
_getIndent = {
if (_depth >= count _indents) then {
_indents set [_depth, (_indents select _depth-1) + " "];
};
_indents select _depth;
};
_writeLine = {
_result = _result + _0D0A + (call _getIndent) + _this;
};
_unwrapTree = {
switch (typeName _this) do {
case "ARRAY": {
"[" call _writeLine;
_depth = _depth + 1;
{ _x call _unwrapTree } foreach _this;
_depth = _depth - 1;
"]," call _writeLine;
};
default {
str _this + "," call _writeLine
};
};
};
_this call _unwrapTree;
copyToClipboard _result;
_result;