Vector_getAddress

Homepage Containers

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

ClassObject := Vector_getAddress(VectorObject, index, useFunction = "")

Parameters

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

Index values start at 1 and "wrap".

Related

Vector_get

Vector_set, Vector_replace, Vector_remove, Vector_discard

Vector

Examples

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

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

;Adds a Vector object (Non-Wrapper) to myVector.
aVector := Vector_new(15)
Vector_add(myVector, aVector)

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

;Returns the object's address.
MsgBox, % "The Vector's address: " . Vector_getAddress(myVector, 2)

Homepage  |  Containers