Ar Find

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
< [[::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

[help]
(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