find: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) mNo edit summary |
No edit summary |
||
Line 54: | Line 54: | ||
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]] | ||
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]] | [[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]] | ||
<!-- CONTINUE Notes --> | |||
<dl class="command_description"> | |||
<dd class="notedate">Posted on January 4, 2015 - 09:38 (UTC)</dd> | |||
<dt class="note">[[User:Heeeere's Johnny!|Heeeere's Johnny!]]</dt> | |||
<dd class="note"> | |||
Using '''[[nil]]''' on either side of '''find''' will make the whole statement return '''nil''': | |||
<code>_array = [1,2,[[nil]],4,5]; | |||
_result = _array '''find''' nil; | |||
[[hintSilent]] [[str]] ([[isNil]] "_result"); //true | |||
_result = nil '''find''' 1; | |||
[[hintSilent]] [[str]] ([[isNil]] "_result"); //true</code> | |||
</dd> | |||
</dl> | |||
<!-- DISCONTINUE Notes --> |
Revision as of 10:38, 4 January 2015
Description
- Description:
- Searches for an array element within array or a string within a string. Returns the 0 based index on success or -1 if not found. Test is cASe-seNsItiVE
- Groups:
- Uncategorised
Syntax
- Syntax:
- array find x
- Parameters:
- array: Array - array to search in
- x: Anything - array element to find
- Return Value:
- Number - 0 based position of the first array element that matches x, -1 if not found
Alternative Syntax
- Syntax:
- string find x (since ["Arma 3","Arma3",127,126674,"Development"])
- Parameters:
- string: String - string to search in
- x: String - string to find
- Return Value:
- Number - 0 based position of the first sequence of characters that matches x, -1 if not found
Examples
- Example 1:
["Apples","Oranges","Pears"] find "Oranges"; //result is 1 [1,[2],[[3]]] find [[3]]; //result is 2
- Example 2:
if (magazines player find "Strela" >= 0) then {hint "You've got Strela!"};
- Example 3:
hint str ("japa is the man!" find "the man!"); //8
Additional Information
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Notes
Bottom Section
- Posted on January 4, 2015 - 09:38 (UTC)
- Heeeere's Johnny!
-
Using nil on either side of find will make the whole statement return nil:
_array = [1,2,nil,4,5]; _result = _array find nil; hintSilent str (isNil "_result"); //true _result = nil find 1; hintSilent str (isNil "_result"); //true