Returns the total number of elements in an array or the number
of elements in a specific dimension.
|
Length := ARRAYLEN(Array[, Dimension])
|
Parameters
- Array
-
Type: Any
The array that you want to investigate.
- Dimension
-
Type: Integer
If you omit this optional argument, the function returns the
total number of elements in the array. To get the number of
elements in a specific dimension, use Dimension with a valid value. The valid values
are determined by the number of dimensions of the input array. For
example, the valid values for a three-dimensional array would be 1,
2, and 3.
Property Value/Return Value
Type: Integer
The number of elements in the array, or the number of elements
in a specific dimension.
Remarks
Example
This example shows how to use the ARRAYLEN
function.
This example requires that you create the following
text constants in the C/AL Globals window.
Text constant |
ENU value |
Text000
|
'Array1, Total number of elements %1'
|
Text001
|
'Array2, Dimension no 1: Size %1'
|
Text002
|
'Array2, Dimension no 2: Size %1'
|
Text003
|
'Array2, Total number of elements: %1'
|
|
Copy Code |
// Array1 is a one-dimensional integer array with size 2
// Array2 is a two-dimensional integer array with size 2x2
MESSAGE(Text000, ARRAYLEN(Array1));
MESSAGE(Text001, ARRAYLEN(Array2,1));
MESSAGE(Text002, ARRAYLEN(Array2,2));
MESSAGE(Text003, ARRAYLEN(Array2));
|
The following messages are displayed.
Array1, Total number of elements: 2
Array2, Dimension no. 1: Size 2
Array2, Dimension no. 2: Size 2
Array2, Total number of elements: 4
See Also