xHarbour Reference Documentation > Function Reference |
Adds one element to the end of an array.
AAdd( <aArray>, <xValue> ) --> xValue
The function returns the value added to the array.
The AAdd() function increases the length of the array <aArray> by one element and assigns the value <xValue> to the new element. It is the last element of <aArray>.
AAdd() dynamically grows an array one element at a time. This is convenient when less than 100 elements should be added to <aArray>. To collect more elements in a loop, for example, it is recommended to dimension the array adequately or to grow multiple elements at a time using the ASize() function.
When <xValue> is of data type Array, a multi-dimensional array is created.
See also: | ADel(), AEval(), AFill(), AIns(), ASize() |
Category: | Array functions |
Source: | vm\arrayshb.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// This example adds 10 numbers to an array and displays a message // after adding each element. PROCEDURE MAIN() LOCAL n, aArray := {} ? Len( aArray ) // result: 0 FOR n := 1 to 10 AAdd( aArray, n ) ? "Added value", n, "to the array." NEXT ? Len( aArray ) // result: 10 RETURN NIL
http://www.xHarbour.com