Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Array

Array( <nElementos1>, [xElemento2], ... [xElemento16] ) --> aRet

Creates an array with specified dimensions.

ArrayAdvPL
01 · OVERVIEW

Overview

Array reserves the requested element count. Additional numeric arguments create dimensions; the page allows up to 16 arguments and states that only the last can be nonnumeric for initialization. A literal can be clearer when starting with known values. Dimensions describe available slots rather than populated records. (TOTVS, s.d., ref. 1)

02 · SYNTAX

Syntax

Array( <nElementos1>, [xElemento2], ... [xElemento16] ) --> aRet

Parameters

nElementos1
NumericRequired

First dimension length.

xElemento2 ... xElemento16
AnyOptional

Additional dimensions or final initializer under the documented rules.

Return value

Array with the specified structure.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function EdArray()
    Local aGrid := Array(2, 2)
    // Assign existing cells; do not assume populated records.
    aGrid[1][1] := "A"
    aGrid[1][2] := 10
    ConOut(cValToChar(Len(aGrid)))
    ConOut(cValToChar(aGrid[1][2]))
Return Nil
Expected result

Expected results: 2 and 10. The second row is not a populated record yet. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Validate external dimensions and limit memory usage. Use AAdd for sequential growth when length is unknown.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Array. TDN. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha