Listlen - MACROMEDIA COLDFUSION MX 61-CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

ListLen

Description
Determines the number of elements in a list.
Integer; the number of elements in a list.
Category
List functions
Function syntax
ListLen(list [, delimiters ])
See also
ListAppend, ListDeleteAt, ListInsertAt,
Parameters
Parameter
list
delimiters
Usage
ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.
Here are some examples of ListLen processing:
Statement
ListLen('a,b, c,,,d')
ListLen('a,b, c,,,d',',')
ListLen('elem_1___elem_2___elem_3')
ListLen('elem*1***elem*2***elem*3')
ListLen('elem_1___elem_2___elem_3','_')
Example
<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>
Description
A list or a variable that contains one.
A string or a variable that contains one. Character(s) that separate list elements.
Default: comma.
If this parameter contains more than one character, ColdFusion processes each
occurrence of each character as a delimiter.
ListPrepend
Output
Comment
4
Third element is
4
Fourth element is
1
1
6
" c"
"d'"
ListLen
579

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents