ListLen

Description

Returns the number of elements in the list.

Category

List functions

Syntax

ListLen(list [, delimiters ]) 

See also

ListAppend, ListDeleteAt, ListInsertAt, ListPrepend.

Parameters

Parameter
Description
list
A list
delimiters
Set of delimiters used in list

Usage


Note

ColdFusion ignores empty list elements; thus, a list that is defined as "a,b,c,,,d" is treated as a four element list.


Example

<!--- This example shows ListGetAt and ListLen --->
<html>
<head>
<title>ListLen Example</title>
</head>
<body>
<H3>ListLen Example</H3>

<!--- Find a list of users who wrote messages --->
<cfquery name = "GetMessageUser" datasource = "cfsnippets">
SELECT Username, Subject, Posted
FROM  Messages
</cfquery>

<cfset temp = ValueList(GetMessageUser.Username)>
<!--- loop through the list and show it with ListGetAt --->
<H3>This is a list of usernames who have posted messages
<cfoutput>#ListLen(temp)#</cfoutput> users.</H3>

<UL>
<CFLOOP From = "1" TO = "#ListLen(temp)#" INDEX = "Counter">
  <cfoutput><LI>Username #Counter#: 
   #ListGetAt(temp, Counter)#</cfoutput>
</CFLOOP>
</UL>
</body>
</html>