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. Todos os direitos reservados. TOTVS, Protheus, Microsiga e seus respectivos logotipos são marcas de titularidade da TOTVS S.A. AdvPL é uma linguagem de programação desenvolvida pela TOTVS. O AdvPL Guia é um projeto independente, sem vínculo, representação, patrocínio ou afiliação com a TOTVS S.A., suas franquias ou representantes.