2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-08-24 19:45:02 +00:00
|
|
|
/*
|
2015-09-05 18:15:31 +00:00
|
|
|
* Author: Glowbal, Jonpas
|
2015-08-24 19:45:02 +00:00
|
|
|
* Makes a list from a string using comma as a delimiter, optionally trim or remove whitespace and check each for object existence.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: List <STRING>
|
|
|
|
* 1: Remove or Trim Whitespace <BOOL> (default: false (trim))
|
|
|
|
* 2: Check Nil <BOOL> (default: false)
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Parsed List <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* ["text", true, false] call ace_common_fnc_parseList
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
params ["_list", ["_removeWhitespace", false], ["_checkNil", false]];
|
|
|
|
|
|
|
|
// Split using comma delimiter
|
2015-09-05 18:15:31 +00:00
|
|
|
_list = _list splitString ",";
|
|
|
|
TRACE_1("Splitted List",_list);
|
2015-08-24 19:45:02 +00:00
|
|
|
|
|
|
|
// Remove or Trim Whitespace
|
2015-12-14 12:08:19 +00:00
|
|
|
private _whitespaceList = [];
|
|
|
|
|
2015-08-24 19:45:02 +00:00
|
|
|
{
|
|
|
|
if (_removeWhitespace) then {
|
2016-09-30 13:51:03 +00:00
|
|
|
_whitespaceList pushBack ([_x] call CBA_fnc_removeWhitespace);
|
2015-08-24 19:45:02 +00:00
|
|
|
} else {
|
|
|
|
_whitespaceList pushBack ([_x] call CBA_fnc_trim);
|
|
|
|
};
|
2015-12-14 12:08:19 +00:00
|
|
|
false
|
2015-09-05 18:15:31 +00:00
|
|
|
} count _list;
|
|
|
|
|
2015-08-24 19:45:02 +00:00
|
|
|
_list = _whitespaceList;
|
2015-09-05 18:15:31 +00:00
|
|
|
TRACE_1("Whitespace List",_list);
|
2015-08-24 19:45:02 +00:00
|
|
|
|
|
|
|
// Check for object existence
|
|
|
|
if (_checkNil) then {
|
2015-12-14 12:08:19 +00:00
|
|
|
private _nilCheckedList = [];
|
|
|
|
|
2015-08-24 19:45:02 +00:00
|
|
|
{
|
2020-02-12 21:07:19 +00:00
|
|
|
if (!isNil _x) then {
|
2015-09-05 18:51:48 +00:00
|
|
|
_nilCheckedList pushBack (missionNamespace getVariable _x);
|
2015-08-24 19:45:02 +00:00
|
|
|
};
|
2015-12-14 12:08:19 +00:00
|
|
|
false
|
2015-08-24 19:45:02 +00:00
|
|
|
} count _list;
|
|
|
|
|
2015-09-05 17:57:35 +00:00
|
|
|
_list = _nilCheckedList;
|
2015-08-24 19:45:02 +00:00
|
|
|
};
|
|
|
|
|
2015-09-05 18:15:31 +00:00
|
|
|
TRACE_1("Final List",_list);
|
2015-08-24 19:45:02 +00:00
|
|
|
|
|
|
|
_list
|