1.7.5.D1202

This commit is contained in:
A Clark
2012-12-07 20:29:23 -06:00
parent 73f951f1cf
commit 5521090b9e
74 changed files with 1258 additions and 576 deletions

View File

@@ -1,59 +1,22 @@
/*
File: inString.sqf
Author: Mika Hannola
private["_findarray","_stringarray","_findcount","_stringcount","_found","_y","_i","_x"];
Description:
Find a string within a string.
Parameter(s):
_this select 0: BOOL - when true, displays all units, otherwise just player positions
_this select 0: <string> string to be found
_this select 1: <string> string to search from
_this select 2 (Optional): search is case sensitive (default: false)
Returns:
Boolean (true when string is found).
How to use:
BIS_fnc_inString = compile preprocessFile "inString.sqf"; //Compile the function
_found = ["string","String",true] call BIS_fnc_inString; //Find a string within a string
*/
private ["_casesensitive","_find","_string","_findarray","_stringarray","_findcount","_stringcount","_found","_match","_y","_i","_x"];
_find = _this select 0;
_string = _this select 1;
//modification : default _casesensitive is false
_casesensitive = false;
if(count(_this) > 2) then {_casesensitive = _this select 2;};
_findarray = toArray _find;
_stringarray = toArray _string;
_findarray = toArray (_this select 0);
_stringarray = toArray (_this select 1);
_findcount = count _findarray;
_stringcount = count _stringarray;
_found = false;
scopeName "main";
if (_findcount <= _stringcount and !_found) then
{
for "_y" from 0 to (_stringcount - _findcount) do
{
_match = [];
for "_i" from 0 to (_findcount - 1) do
{
_match set [count _match,_stringarray select (_y + _i)];
};
_found = true;
if (_findcount <= _stringcount) then {
for "_y" from 0 to (_stringcount - _findcount) do {
_i = 0;
{
if (_x != _match select _i) then
{
_found = false;
};
scopeName "loop1";
if (_x == (_stringarray select (_y + _i))) then {
_i = _i + 1;
} else {breakOut "loop1";};
} forEach _findarray;
if (_found) then {breakTo "main";};
if (_i == _findcount) then {_found = true; breakTo "main";};
};
};
_found;
_found