Function ASize() Foundation

Changes the number of elements in an array.

Syntax
ASize( <aArray>, <nElements> ) --> aArray
Parameters
<aArray>
<aArray> is the array whose size is changed.
<nElements>
<nElements> is a numeric value which determines the number of elements included in the array <aArray>.
Return

ASize() returns the reference to <aArray>.

Description

The array function ASize() increases or decreases the number of elements in an array. When the array is lengthened, the new elements are at the end of the array and have the value NIL. If the array is shortened, the elements at the end of the array are deleted and their contents are lost.

Another function which changes the size of an array is AAdd() which attaches a single array element at the end and optionally assigns it a value. The contents of array elements can also be manipulated with the functions AIns() and ADel(), which do not change the size of the array.

The number of elements in an array is not limited by Xbase++.

Examples
Dynamically change the size of an array using ASize()

// The example shows the effect of ASize() on an array. 

PROCEDURE Main 
   LOCAL aArray := {"A","B","C"} 

   ASize( aArray, 5 )      // aArray is: {"A","B","C",NIL,NIL} 
   ASize( aArray, 2 )      // aArray is: {"A","B"} 

RETURN 

Feedback

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.