ALEN( )
Topic group Related topics Example
Returns the number of elements, rows, or columns of an array.
Syntax
ALEN(<array> [, <expN>])
<array>
A reference to a one- or two-dimensional array.
<expN>
The number 0, 1, or 2, indicating which array information to return: elements, rows, or columns. The following table describes what ALEN( ) returns for different <expN> values:
If <expN> is... |
ALEN( ) returns... |
not supplied |
Number of elements in the array |
0 |
Number of elements in the array |
1 |
For a one-dimensional array, the number of elements |
|
For a two-dimensional array, the number of rows (the first subscript of the array) |
2 |
For a one-dimensional array, 0 (zero) |
|
For a two-dimensional array, the number of columns (the second subscript of the array) |
any other value |
0 (zero) |
Property of
Array
Description
Use ALEN( ) to determine the dimensions of an array—either the number of elements it contains, or the number of rows or columns it contains.
The number of elements in an array (with any number of dimensions) is also reflected in the array’s size property.
If you need to determine both the number of rows and the number of columns a two-dimensional array contains, call ALEN( ) twice, once with a value of 1 for <expN> and once with a value of 2 for <expN>. For example, the following determines the number of rows and columns contained in aExample:
nRows = alen( aExample, 1 )
nCols = alen( aExample, 2 )