Skip to main content

$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"))

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

PRINT $LISTLENGTH("")

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)

See Also

FeedbackOpens in a new tab