Ar Prev

From GECK
Jump to: navigation, search


A function added by the New Vegas Script Extender.

Description

Returns the previous key of an array, after that specified. For regular arrays (list arrays) this is just equivalent to (SpecifiedKey - 1). This function is most useful for map and stringmap arrays, where keys are dynamic. Note that map and stringmap arrays are always sorted in ascending numeric or alphanumeric order, regardless of the order of element insertion.

Returns a bad index (Ar_BadNumericIndex or Ar_BadStringIndex) if there is no previous key in the array.

Syntax

[help]
(key:int-or-float-or-string) Ar_Prev Source:array Next:key 

Example

array_var MyMap
int iKey ; * or float/string_var as appropriate for array

let iKey := Ar_Last MyMap ; * get last element

while iKey != Ar_BadNumericIndex
    ; do something for every valid key in array, in reverse order
    let iKey := Ar_Prev MyMap, iKey
loop

See Also