Skip to content

Instantly share code, notes, and snippets.

@GeorgeDettmer
Last active September 26, 2015 19:27
Show Gist options
  • Save GeorgeDettmer/b7f63deabdcf57d0cb7d to your computer and use it in GitHub Desktop.
Save GeorgeDettmer/b7f63deabdcf57d0cb7d to your computer and use it in GitHub Desktop.
/*
Author:
Moses
Description:
Search config for classes containing search string
Parameter(s):
0: ANY - String to be used in search, if not string it is still used.
1: ARRAY/STRING - Config(s) to search
Returns:
ARRAY - list of matching results
Example:
["30rnd",["CfgWeapons","CfgMagazines"]] execVM "findClass.sqf"
["box","CfgVehicles"] execVM "findClass.sqf"
Note:
Global variable 'class_search_results' is set to the result of the search
*/
params [
["_search","",["",objNull]],
["_config",["CfgVehicles","CfgMagazines","CfgWeapons"],["",[]]]
];
if (typeName _search != "STRING") then {
_search = str _search
};
if (typeName _config == "STRING") then {
_config = [_config]
};
_search = toLower _search;
_results = [];
{
_results append (format['toLower configName(_x) find "%1" != -1',_search] configClasses (configFile >> _x))
} count _config;
_classes = [];
{_classes pushBack (configName _x); false} count _results;
class_search_results = _classes;
copyToClipboard format["Search results: %1",_classes];
_classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment