LENGTH

Use the LENGTH script function to retrieve the size of a script array. The function returns the number of elements in the script array, or the number of filled array elements.

Syntax

LENGTH (script array [,SIZE])

Parameters


Note: The maximum size of a script array is 99999. For more information about script arrays, see Arrays.

Important! A script error occurs if the specified array cannot be found or if you specify a script variable instead of a script array. Ensure that you use empty square brackets to specify your array.

Example

The following example creates a script array, and fills the array with values from a VARA object. The script uses a loop to write the results to the activation report.

:DEFINE &ARRAY#, string, 5
:SET &LEN# = LENGTH(&ARRAY#[])
:SET &VAR# = 1

:FILL &ARRAY#[] = GET_VAR(VARA1, ARRAY)
:WHILE &VAR# LE &LEN#
:PRINT "Element &VAR# = &ARRAY#[&VAR#]"
:SET &VAR# = &VAR# + 1
:ENDWHILE

See also: