Array_set

Homepage Containers

Destroys the element stored at the specific position in the Array object, and replaces it with the new object.

Result := Array_set(ArrayObject, index, object = 0)

Parameters

ArrayObject The Array object to use for the current operation.
index Index of element to set.
object The class object to store at the specified position.

Return Value

True (1) if the previous object was destroyed,
False (0) if the new object is the same as the old,
or a negative number, the lock count (as a negative), if the previous object still exists (see remarks).

Remarks

If ArrayObject is NULL (0 or blank), the empty string is returned, to indicate an error.

When setting an object, the previous object is destroyed. Call Array_replace, instead, if you wish to only replace the previous object. The object will not be destroyed if the lock count for the element is more than one. In this case, the lock count will be decreased by one, and Result will be the negative of the new lock count. So, if Result < 0, -Result is the lock count for the previous object (see an example, below, for use).

Index values start at 1 and "wrap".

Related

Array_get, Array_getAddress

Array_replace

Array

Examples

;Creates a new Array (of length 10).
myArray := Array_new(10)

;Sets myArray[1] to a aString.
aString := String_new("Item1")
Array_set(myArray, 1, aString)

;Outputs the new item.
MsgBox, % "myArray, index 1: " . Array_get(myArray, 1)

Homepage  |  Containers