Function AAdd() Foundation
Enlarges an array by one element.
AAdd( <aArray>, <Expression>, [<nElement>] ) --> xValue
The return value of AAdd() is the value of <Expression>.
The array function AAdd() adds one element to an existing array. The new element is the last element in the array or the element at the position <nElement>. The new element has the value associated with <Expression>. The length of the array is not limited in Xbase++.
AAdd() is used to manage dynamic lists. The function ASize() has a similar purpose, allowing the size of any array to be set. The advantage of AAdd() is that the value <Expression> is also assigned to the new element.
When the value of <Expression> is an array, the new element in <aArray> contains a reference to the array specified in <Expression>. <aArray> then becomes a multi-dimensional array.
// The example demonstrates the use of AAdd() with various
// data types. In the first series, elements are added at the end
// of the array, in the second elements are inserted into the
// array.
PROCEDURE Main
LOCAL aArray := {} // aArray is an empty array
AAdd( aArray, .T.) // aArray is {.T.}
AAdd( aArray, "A") // aArray is {.T., "A"}
AAdd( aArray, Asc("A") ) // aArray is {.T., "A", 65}
AAdd( aArray, NIL ) // aArray is {.T., "A", 65, NIL}
AAdd( aArray, {"NAME","C",20,0} )
// aArray is
// {.T., "A", 65, NIL, {"NAME","C",20,0} }
aArray := {}
AAdd( aArray, .T.) // aArray is {.T.}
AAdd( aArray, "A",1 ) // aArray is {"A",.T.}
AAdd( aArray, Asc("A"), 2 ) // aArray is {"A", 65,.T.}
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.