Array_getAddress

Homepage Containers

Returns the address for the object stored in the Array at the specified position.

ClassObject := Array_getAddress(ArrayObject, index, useFunction = "")

Parameters

ArrayObject The Array object to use for the current operation.
index Index of element whose address is returned.
useFunction

If specified, this is the function to call on the object. For example, if useFunction were "size", and the object at the specified index is an Array, Array_size(object) would be called; whereas if the object were a Vector, Vector_size(object) is called.

Note: the passed object is the object at the specified index in this Vector. Also, the function is called by passing only one argument, the object. As such, this feature is primarily used to retrieve a field in the object (e.g. the size).

Return Value

Address for the object stored at the specified position.

If there is no object set at the specified position, 0 is returned.


The function's return can be used as a quasi-boolean value; the statement if Array_getAddress(...) would be true if the element is set, and false otherwise.

If useFunction is specified, the function with the same name located inside of the object's class will be dynamically called, and its return will be returned.

Remarks

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

Index values start at 1 and "wrap".

Related

Array_get

Array_set, Array_replace

Array

Examples

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

;Sets myArray[1] to a String object (Wrapper).
aString := String_new("Hello World!")
Array_set(myArray, 1, aString)

;Sets myArray[2] to an Array object (Non-Wrapper).
anArray := Array_new(15)
Array_set(myArray, 2, anArray)

;Returns the object's address, even for a wrapper object.
MsgBox, % "The String's address: " . Array_getAddress(myArray, 1)

;Returns the object's address.
MsgBox, % "The Array's address: " . Array_getAddress(myArray, 2)

Homepage  |  Containers