DeleteArrayItem

(Engine-Level Function)

Description: Deletes an element from a single-dimension, dynamically-allocated array and returns the modified array.
Returns: Array
Usage: Script Only.
Function Groups: Array
Related to: InsertArrayItem | New
Format: DeleteArrayItem(Array, Index)
Parameters:  
Array   
Required. Any array variable that has been created via a New function call. This should be a single dimension array or unexpected results may occur.
Index   
Required. Any numeric expression giving the element in the array to delete. If out of range, then the original array will be returned.
Comments: This function supersedes the System Library's DeleteListItem.
This function is intended for use on dynamically allocated arrays; that is, arrays that have been created via the New function. If used with an array that has been statically declared, unless otherwise specified in the Array parameter, the first element of the array will be used. If this element contains a dynamically allocated array, the deletion of the specified element will be performed on this array.

Example:

  If 1 Next;
  [
    Data = DeleteArrayItem(Data, ArraySize(Data, 0) - 1);
  ]

This statement deletes the last element in the array called Data.