Files
DayZ-Epoch/SQF/dayz_code/actions/AdvancedTrading/functions/KK_fnc_inString.sqf
icomrade 1585765ca6 Advanced trading by Zupa @Windmolders
Stock configuration and basic integration. WE still need config based
trader setups.
2016-04-27 18:23:55 -04:00

30 lines
825 B
Plaintext

/*
* Author: Killzone_Kid
*
* Description:
* Find a string within a string (case insensitive)
*
* Parameter(s):
* _this select 0: <string> string to be found
* _this select 1: <string> string to search in
*
* Returns:
* Boolean (true when string is found)
*
* How to use:
* _found = ["needle", "Needle in Haystack"] call KK_fnc_inString;
*/
private ["_needle","_haystack","_needleLen","_hay","_found"];
_needle = [_this, 0, "", [""]] call BIS_fnc_param;
_haystack = toArray ([_this, 1, "", [""]] call BIS_fnc_param);
_needleLen = count toArray _needle;
_hay = +_haystack;
_hay resize _needleLen;
_found = false;
for "_i" from _needleLen to count _haystack do {
if (toString _hay == _needle) exitWith {_found = true};
_hay set [_needleLen, _haystack select _i];
_hay set [0, "x"];
_hay = _hay - ["x"]
};
_found