This function returns the number of elements, rows or columns in an array. For one-dimensional arrays, it returns the number of elements. For two-dimensional arrays, a parameter determines whether it returns elements, rows or columns. We often forget to include the parameter when asking for rows and end up with elements by accident. A better approach is to always pass 1 for the second parameter unless you specifically want the number of columns. With a one-d array, you still get the number of elements, but for a two-d array, you'll get rows, which is what we almost always want.
nReturnValue = ALEN( ArrayName [, nElemRowOrCol ] )|
Parameter |
Value |
Meaning |
|
ArrayName |
Array Name |
The array whose elements, rows or columns are to be counted. Can be either one- or two-dimensional. |
|
nElemRowOrCol |
0 or Omitted |
Returns the number of elements in the array. |
|
1 |
Returns the number of rows in a two-dimensional array. For a one-dimensional array, returns the number of elements. |
|
|
2 |
Returns the number of columns in a two-dimensional array. Returns 0 for a one-dimensional array. |
|
|
nReturnValue |
Numeric |
The number of elements, rows or columns in ArrayName. |
USE Employee
COPY TO ARRAY aEmps FIELDS Last_Name, First_Name
nCount = ALEN(aEmps,1)
* check if an array is two-dimensional
IF ALEN(MyArray, 2) = 0
* one-dimensional
ELSE
* two-dimensional
ENDIFAlso, see the function aColCopy() under ACOPY() for examples of ALEN() in use.
ACopy(), AElement(), Array Manipulation, ASubscript(), Dimension