ARRAYSIZE

The ARRAYSIZE function is used to return the maximum number of elements that an array variable can hold. For example, you can use it to return the upper bound index for a declared array. The elements of array %%AR are referenced as %%AR[0], %%AR[1],..%AR[n-1] where n = ARRAYSIZE[%%AR].

Note: Array indices are zero based. For example, the first valid index in a declared array is 0 and the last is arraysize -1.

Syntax

ARRAYSIZE(variable)

Arguments

Argument Description Default
variable Name of array. None

Results

Result Description
Return Number of elements in the array. 0 if not an array.
%%RC 0 for an array, -1 if variable is not array.
%%RM A null string ('').
%%RV A null string ('').

Examples

Function Call Return %%RC
DECLARE(%%Var, "A", 6)

%%ans = ARRAYSIZE(%%Var)

6 0
%%ans = ARRAYSIZE(%%ZZZ) 0 -1