Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
KC Grimes

Q: Search for specific characters in array or variable

Recommended Posts

Howdy! I came across another idea today, but am unfortunately barred by my lack of knowing a certain work around or even an already implemented command. I am trying to separate the Titan launchers into arrays for their respective factions (each faction has 2 Titans). My idea to do this, since the Cfg has no side indication, was to check for text, since BLUFOR has launch_B, OPFOR has launch_O, and IND has launch_I as the prefix for the classname. Here's what I tried, which obviously failed:

Assuming the command "in" meant if the variable/array contained this string, partial or complete, return true (In reality, it only checks for complete match, not partial).

if ("launch_B" in [_classname]) then {
_NATO_Launcher_Array set[count _NATO_Launcher_Array, _classname];
};

When _classname is launch_B_titan_F, it should add it to the array, and when it is launch_O_titan_F it should skip it, not adding it to the array.

Basically, I am looking for a way to check for partial matches of strings. Is this possible? Sorry for being a little all over the place, if further clarification is needed please let me know.

Thanks!

Edit: Another way to ask is, is there a "wildcard" (* or %) like in other languages?

Edited by Grimes [3rd ID]

Share this post


Link to post
Share on other sites

BIS_fnc_inString might be what you're after.

if ( ["launch_b", _classname] call BIS_fnc_inString) then{
_NATO_Launcher_Array set[count _NATO_Launcher_Array, _classname];
};

Share this post


Link to post
Share on other sites
BIS_fnc_inString might be what you're after.

if ( ["launch_b", _classname] call BIS_fnc_inString) then{
_NATO_Launcher_Array set[count _NATO_Launcher_Array, _classname];
};

Exactly what I was looking for. Love these ArmA 3 functions! Thanks for the quick help!

Share this post


Link to post
Share on other sites
;2609869']Exactly what I was looking for. Love these ArmA 3 functions! Thanks for the quick help!

My pleasure!

Share this post


Link to post
Share on other sites
Sign in to follow this  

×