ListGetAt

Description

Returns the element at a given position.

Category

List functions

Syntax


ListGetAt(list, position [, delimiters ]) 

See also

ListFirst, ListLast, ListQualify, ListSetAt

Parameters

Parameter
Description
list
List whose element to retrieve
position
Positive integer; position of the element to retrieve
delimiters
Set of delimiters used in list

Usage

The first position in a list is denoted by the number 1, not 0.


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>ListGetAt Example</title>

</head>

<body>

<H3>ListGetAt 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 list of usernames who have posted messages numbers

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



Banner.Novgorod.Ru