Vector_get |
Homepage Containers |
Returns the value for the object stored in the Vector at the specified position.
value := Vector_get(VectorObject, index, useFunction = "")
| VectorObject | The Vector object to use for the current operation. |
| index | Index of element whose value 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). Additionally, if the specified object is a wrapper object, it will not be unwrapped first. |
If the object at the specified position is a wrapper, then its contents are "unwrapped" and returned.
Otherwise, the address for the object is returned.
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.
If VectorObject is NULL (0 or blank), the empty string is returned, to indicate an error.
To always get the address of a Class object, even for Wrapper objects, call Vector_getAddress instead.
Index values start at 1 and "wrap".
Vector_set, Vector_replace, Vector_remove, Vector_discard
;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) ;Unwraps the String object and returns "Hello World!" MsgBox, % "The unwrapped String: " . Vector_get(myVector, 1) ;Since Vector is not a Wrapper class, the object's address is returned instead. MsgBox, % "The Vector's address: " . Vector_get(myVector, 2)