Ar Find

Revision as of 21:56, 27 May 2014 by imported>Odessa (created)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
< [[::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

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 JohnREF, aBeatles) < (Ar_Find PaulREF, aBeatles)
    ; * John is found earlier in the array than Paul

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