aDestinoArray that receives the new last element and is resized.
AdvPL GuideAAdd( <aDestino>, <xExpressao> ) → xExpressaoAppends one element to an array and increases its size by one position.
AAdd() appends the value of any valid AdvPL expression to an array and returns that value. It is useful for lists, queues and matrix rows whose size is not known in advance.
AAdd( <aDestino>, <xExpressao> ) → xExpressaoaDestinoArray that receives the new last element and is resized.
xExpressaoValue assigned to the new position; it may also be another array.
Returns the value supplied in xExpression, not necessarily the destination array.
User Function ExAAddNames()
Local aNames := {}
AAdd(aNames, "Alice")
AAdd(aNames, "Bruno")
AAdd(aNames, "Carla")
MsgInfo(aNames[3], "Third name")
ReturnThe array contains three values and position 3 contains “Carla”.
// See the Portuguese example; localize only user-facing text.Each main-array element is a row containing a name and an age.
User Function ExAAddReferencia()
Local aDestino := {}
Local aLinha := {"Produto", 10}
Local xRetorno := AAdd(aDestino, aLinha)
aLinha[2] := 20
ConOut(xRetorno[2]) // 20
ConOut(aDestino[1][2]) // 20
ReturnThe return value is the appended row, and later source-array changes are visible through the stored reference.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.