Automation Engine Script Guide > Ordered by Function > Script Structure and Processing > LENGTH

LENGTH

Script function: It retrieves the size of a script array.

Syntax

LENGTH(Script-Array, [SIZE])

Syntax

Description/Format

Script array

The name of the script variable that has been defined as an array.
Format: script variables

SIZE Ignores the empty elements at the end of the array.

Return codes

The number of script array elements.

Comments 

You can create script arrays by using the script element :DEFINE in which you can also determine the data type and the number of elements. Subsequently, you can query the array size using the script function LENGTH. You use empty brackets [] in order to indicate that it is an array..

The maximum size of a script array is 99999.

A script error will occur when the specified array cannot be found or when you specify a script variable.

When you specify the parameter SIZE, this script function only returns the number of filled array elements. The empty elements at the end of the array are ignored.

Note that for retrieving the size up to the last filled element (SIZE parameter), the array must have the data type "string". All other data types will always return the total array size.

Examples

The following example creates a script array, fills it with values from a Variable object and outputs these values with a loop.

: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:

Script Element Description

:FILL

Stores several values to a script array.

FIND Searches through a script array and returns the corresponding index.