Ar Erase

< [[::Category:Functions|Category:Functions]]

A function added by the New Vegas Script Extender.

Description

Erases the entry at the specified index, if it exists, from the specified array. The index may be specified using range notation to delete all elements with indices within the range, inclusively. Alternatively, the index argument may be omitted to erase all entries in an array. Returns the count of entries erased.

The array may be of any type, but the index must be appropriate to it (int or string). Arrays of type "array" (Ar_List) are always indexed consecutively, so any entries above the erased will have their keys shifted down.

Syntax

(int) Ar_Erase Parent:array ToErase:index-or-range

Example

Ar_Erase SomeArray, SomeKey ; erases the entry at SomeKey from SomeArray

Additional Context

array_var aBeatles

let aBeatles := Ar_List JohnREF, PaulREF, GeorgeREF, RingoREF

Ar_Erase aBeatles, 4 ; does nothing because 4 is not a valid index

Ar_Erase aBeatles, 1:2 ; erases entries from 1 to 2

; aBeatles now contains: JohnREF, RingoREF

Ar_Erase aBeatles, 0 ; erases entry at key 0

; aBeatles now only contains: RingoREF

See Also