Array_clear

Homepage Containers

Destroys (and unsets) each item in the Array. Note: calling this function will not change the Array's length.

Result := Array_clear(ArrayObject)

Parameters

ArrayObject The Array object to use for the current operation.

Return Value

True (1) to indicate the Array was successfully cleared.

Remarks

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

Calling this function does not destroy the Array object - only the data within. To destroy the Array object, call Array_destroy instead.

Related

Array_destroy

Array

Examples

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

;Adds two items to myArray
Array_set(myArray, 1, String_new("Item1"))
Array_set(myArray, 2, String_new("Item2"))

;Outputs the current values
MsgBox, % "Before clear:`n"
    . "Value1: " . Array_get(myArray, 1) . "`n"
    . "Value2: " . Array_get(myArray, 2)

;Clears the Array
Array_clear(myArray)

;myArray is now empty
MsgBox, % "After clear:`n"
    . "Value1: " . Array_get(myArray, 1) . "`n"
    . "Value2: " . Array_get(myArray, 2)

;Outputs the Array's length (10) - note that the length remains the same.
;Note: the Array still exists, so its address is still valid.
MsgBox, % "myArray has " Array_length(myArray) " elements."

Homepage  |  Containers