Ar Find
From GECK
(Redirected from Ar find)
A function added by the New Vegas Script Extender.
Contents
Description
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
See Also
- Ar_HasKey to check if a key is in an array, instead of a value.
- Array Variables
- Let
- Eval
- Ar_List
- Ar_BadNumericIndex
- Ar_BadStringIndex