2015-06-27 02:11:57 +00:00
|
|
|
/*
|
|
|
|
* Author: Jonpas
|
|
|
|
* Makes a list from a string using comma as a delimiter, optionally remove whitespace and check each for object existence.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Text <STRING>
|
2015-08-23 17:48:57 +00:00
|
|
|
* 1: Trim Whitespace <BOOL>
|
2015-06-27 02:11:57 +00:00
|
|
|
* 2: Check Nil <BOOL>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* Parsed List <ARRAY>
|
|
|
|
*
|
|
|
|
* Example:
|
2015-07-16 21:16:09 +00:00
|
|
|
* ["text", true, false] call ace_slideshow_fnc_makeList
|
2015-06-27 02:11:57 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-08-23 17:48:57 +00:00
|
|
|
#define DEBUG_MODE_FULL
|
2015-06-27 02:11:57 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-23 17:48:57 +00:00
|
|
|
params ["_list", "_trimWhitespace", "_checkNil"];
|
2015-06-27 02:11:57 +00:00
|
|
|
|
2015-08-23 17:48:57 +00:00
|
|
|
private ["_splittedList", "_listTrimmedWhitespace", "_nilCheckPassedList"];
|
2015-06-27 02:11:57 +00:00
|
|
|
|
|
|
|
// Split using comma delimiter
|
|
|
|
_splittedList = [_list, ","] call BIS_fnc_splitString;
|
|
|
|
|
|
|
|
// Remove whitespace
|
2015-08-23 17:48:57 +00:00
|
|
|
_listTrimmedWhitespace = [];
|
|
|
|
if (_trimWhitespace) then {
|
2015-06-27 02:11:57 +00:00
|
|
|
{
|
2015-08-23 17:48:57 +00:00
|
|
|
_listTrimmedWhitespace pushBack ([_x] call CBA_fnc_trim);
|
2015-08-07 10:11:34 +00:00
|
|
|
nil
|
|
|
|
} count _splittedList;
|
2015-08-23 17:48:57 +00:00
|
|
|
_list = _listTrimmedWhitespace;
|
2015-06-27 02:11:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Check for object existence
|
|
|
|
_nilCheckPassedList = "";
|
|
|
|
if (_checkNil) then {
|
|
|
|
{
|
|
|
|
if !(isNil _x) then {
|
|
|
|
if (_nilCheckPassedList == "") then {
|
|
|
|
_nilCheckPassedList = _x;
|
|
|
|
} else {
|
|
|
|
_nilCheckPassedList = _nilCheckPassedList + "," + _x;
|
|
|
|
};
|
|
|
|
};
|
2015-08-07 10:11:34 +00:00
|
|
|
} count _list;
|
2015-06-27 02:11:57 +00:00
|
|
|
|
|
|
|
// Add Array characters and parse into array
|
|
|
|
_list = "[" + _nilCheckPassedList + "]";
|
|
|
|
_list = [] call compile _list;
|
|
|
|
};
|
|
|
|
|
2015-08-23 17:48:57 +00:00
|
|
|
TRACE_4("Lists",_splittedList,_listTrimmedWhitespace,_nilCheckPassedList,_list);
|
2015-06-27 02:11:57 +00:00
|
|
|
|
2015-08-07 10:11:34 +00:00
|
|
|
_list // return
|