array_length

This function gets the length (number of entries) of an array dimension.

You supply the array index value and the function will return an integer value representing the number of entries the array contains. This function can also be used for multi-dimension arrays, as long as you specify which dimension you want to get the length of when you supply the array index, following this pattern:

// Returns the first dimension of the array
val = array_length(my_array);

// Returns the second dimension of the array
val = array_length(my_array[0]);

// Returns the third dimension of the array
val = array_length(my_array[0][0]);

// etc.

NOTE The function returns 0 in case a data type that's not an Array is passed to it.

 

Syntax:

array_length(array_index);

Argument Type Description
array_index Array The array to check.

 

Returns:

Real

 

Example:

for (var i = 0; i < array_length(a); ++i)
{
    a[i] = -1;
}

The above code will loop through an array and set each entry to -1.