Vector_set

Homepage Containers

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

Result := Vector_set(VectorObject, index, object = 0)

Parameters

VectorObject The Vector 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 VectorObject is NULL (0 or blank), the empty string is returned, to indicate an error.

When setting an object, the previous object is destroyed. Call Vector_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.

Index values start at 1 and "wrap".

Related

Vector_get, Vector_getAddress

Vector_replace, Vector_remove, Vector_discard

Vector

Examples

;Creates a new Vector with the default parameters.
myVector := Vector_new()

;Adds a String object to myVector.
aString := String_new("Hello World!")
Vector_add(myVector, aString)

;Sets myVector[1] to a new object (destroying the old object).
aString2 := String_new("Item1")
Vector_set(myVector, 1, aString2)

;Outputs the new item.
MsgBox, % "myVector, index 1: " . Vector_get(myVector, 1)

Homepage  |  Containers