Skip to main content
Previous sectionNext section

$LISTLENGTH ($LL)

Returns the number of elements in a specified list.

Synopsis

$LISTLENGTH(list)
$LL(list)

Parameter

list An expression that resolves to a Caché list. A Caché list is created using $LISTBUILD or $LISTFROMSTRING, or extracted from another list using $LIST.

Description

$LISTLENGTH returns the number of elements in list.

Examples

The following example returns 3, because there are 3 elements in the list:

PRINT $LISTLENGTH($LISTBUILD("Red","Blue","Green"))
Copy code to clipboard

The following example returns a 0, because a null string is a valid (zero-element) list.

PRINT $LISTLENGTH("")
Copy code to clipboard

Notes

$LISTLENGTH and Nested Lists

The following example returns 3, because $LISTLENGTH does not recognize the individual elements in nested lists:

x=$LISTBUILD("Apple","Pear",$LISTBUILD("Walnut","Pecan"))
PRINT $LISTLENGTH(x)
Copy code to clipboard

See Also