Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

ASize

ASize( <aDestino>, <nTamanho> ) --> Nil

Resizes an existing array.

ASizeAdvPL
01 · OVERVIEW

Overview

ASize changes the element count. Shrinking discards final positions and contents; growing does not create complete business records. The consulted page declares a Nil return, so the example calls it as a statement and keeps the array in its original variable. Recheck valid indexes after shrinking. (TOTVS, s.d., ref. 1)

02 · SYNTAX

Syntax

ASize( <aDestino>, <nTamanho> ) --> Nil

Parameters

aDestino
ArrayRequired

Array to resize.

nTamanho
NumericRequired

New length.

Return value

Nil according to the consulted page. The effect applies to the supplied array.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function EdAsize()
    Local aItems := {10, 20, 30}
    // Do not assign the ASize return to aItems.
    ASize(aItems, 2)
    ConOut(cValToChar(Len(aItems)))
    ConOut(cValToChar(aItems[2]))
Return Nil
Expected result

Expected results: 2 and 20. Element 30 was discarded. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Validate a nonnegative integer length. Use AClone before shrinking when the original structure must be retained.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. ASize. 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