ACE3/addons/common/functions/fnc_dumpArray.sqf

45 lines
877 B
Plaintext
Raw Normal View History

2015-09-20 20:16:51 +00:00
/*
* Author: ?
2015-10-04 02:34:46 +00:00
* Dumps an array to the RPT, showing the depth of each element.
2015-09-20 20:16:51 +00:00
*
* Arguments:
* 0: Array to be dumped <ARRAY>
2015-10-04 02:34:46 +00:00
* 1: Depth <NUMBER><OPTIONAL>
2015-09-20 20:16:51 +00:00
*
* Return Value:
* None
*
2015-10-04 02:34:46 +00:00
* Example:
* [[0, [1,2], [[3]]]] call ace_common_fnc_dumpArray
*
2015-09-20 20:16:51 +00:00
* Public: No
*/
2015-03-10 19:59:40 +00:00
#include "script_component.hpp"
2015-10-04 02:34:46 +00:00
params ["_var", ["_depth", 0, [0]]];
2015-03-10 19:59:40 +00:00
2015-11-17 16:43:07 +00:00
private _pad = "";
2015-05-14 18:06:06 +00:00
2015-03-10 19:59:40 +00:00
for "_i" from 0 to _depth do {
_pad = _pad + toString [9];
2015-03-10 19:59:40 +00:00
};
2015-05-14 18:06:06 +00:00
2015-03-10 19:59:40 +00:00
_depth = _depth + 1;
2015-05-14 18:06:06 +00:00
if (IS_ARRAY(_var)) then {
2015-09-20 22:34:04 +00:00
if (_var isEqualTo []) then {
2015-09-20 23:07:49 +00:00
diag_log text format ["%1[],", _pad];
2015-09-20 22:34:04 +00:00
} else {
2015-09-20 23:07:49 +00:00
diag_log text format ["%1[", _pad];
2015-09-20 20:16:51 +00:00
{
[_x, _depth] call FUNC(dumpArray);
2015-09-20 20:16:51 +00:00
false
} count _var;
2015-09-20 23:07:49 +00:00
diag_log text format ["%1],", _pad];
};
2015-03-10 19:59:40 +00:00
} else {
2015-10-04 02:34:46 +00:00
diag_log text format ["%1%2", _pad, _var];
2015-03-10 19:59:40 +00:00
};