User Guide
ListSetAt 585
ListSetAt
Description
Replaces the contents of a list element.
Returns
A copy of a list, with a new value assigned to the element at a specified position.
Category
List functions
Function syntax
ListSetAt(list, position, value [, delimiters ])
See also
ListDeleteAt, ListGetAt, ListInsertAt
History
ColdFusion MX: Changed delimiter modification: ColdFusion MX does not modify delimiters
in the list. (In earlier releases, in some cases, replaced delimiters with the first character in the
delimiters parameter.)
Parameters
Usage
When assigning an element to a list, ColdFusion inserts a delimiter. If delimiters contains more
than one delimiter, ColdFusion uses the first delimiter in the string, or, if delimiters was
omitted, a comma.
ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.
Example
<h3>ListSetAt 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.Subject)>
<!--- loop through the list and show it with ListGetAt --->
<h3>This is a list of <cfoutput>#ListLen(temp)#</cfoutput>
Parameter Description
list A list or a variable that contains one.
position A positive integer or a variable that contains one. Position at which to set a value.
The first list position is 1.
value An element or a list of elements.
delimiters 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.