Difference between revisions of "Ar Find"
Jump to navigation
Jump to search
imported>Odessa (created) |
imported>Odessa (Clarirified examples) |
||
(One intermediate revision by the same user not shown) | |||
Line 13: | Line 13: | ||
|Type = range}}}} | |Type = range}}}} | ||
==Example== | ==Example== | ||
A numeric indexed array ("array" or "map"): | |||
<pre> | |||
if eval (Ar_Find SomeValue, SomeArray) != Ar_BadNumericIndex | |||
; then SomeValue is an element in SomeArray | |||
endif | |||
</pre> | |||
A string indexed array ("stringmap"): | |||
<pre> | |||
if eval (Ar_Find SomeValue, MyStringMap) != Ar_BadStringIndex | |||
; then SomeValue is an element in MyStringMap | |||
endif | |||
</pre> | |||
Another numeric example, with extra context: | |||
<pre> | <pre> | ||
array_var aBeatles | array_var aBeatles | ||
Line 20: | Line 35: | ||
if eval (Ar_Find RingoREF, aBeatles) != Ar_BadNumericIndex | if eval (Ar_Find RingoREF, aBeatles) != Ar_BadNumericIndex | ||
; * Ringo is found somewhere in the array aBeatles | ; * Ringo is found somewhere in the array aBeatles | ||
elseif eval (Ar_Find GeorgeREF, aBeatles, 1:2) != Ar_BadNumericIndex | elseif eval (Ar_Find GeorgeREF, aBeatles, 1:2) != Ar_BadNumericIndex | ||
Line 30: | Line 42: | ||
</pre> | </pre> | ||
==See Also== | ==See Also== | ||
*[[Array Variables]] | *[[Array Variables]] |
Latest revision as of 18:44, 28 June 2014
< [[::Category:Functions|Category:Functions]]
A function added by the New Vegas Script Extender.
Description
Added by NVSE V4. Returns the key of the first occurrence of a value in an array, or optionally within a sub range of the array. If the value searched for is not found, it returns the constant Ar_BadNumericIndex (-99999.0) for numeric indexed arrays, or the constant Ar_BadStringIndex (empty string) for those that are string indexed.
Syntax
(int-OR-string) Ar_Find Value:multi ToSearch:array Subrange:range
Example
A numeric indexed array ("array" or "map"):
if eval (Ar_Find SomeValue, SomeArray) != Ar_BadNumericIndex ; then SomeValue is an element in SomeArray endif
A string indexed array ("stringmap"):
if eval (Ar_Find SomeValue, MyStringMap) != Ar_BadStringIndex ; then SomeValue is an element in MyStringMap endif
Another numeric example, with extra context:
array_var aBeatles let aBeatles := Ar_List JohnREF, PaulREF, GeorgeREF, RingoREF ; * example context if eval (Ar_Find RingoREF, aBeatles) != Ar_BadNumericIndex ; * Ringo is found somewhere in the array aBeatles elseif eval (Ar_Find GeorgeREF, aBeatles, 1:2) != Ar_BadNumericIndex ; * George is found within the subrange (second to third elements) of array endif