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)
| 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. |
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".
;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)