Assigns a value to a list element.
A copy of a list, with a value assigned to the element at a specified position.
ListSetAt(list, position, value [, delimiters ])
ListDeleteAt,
ListGetAt,
ListInsertAt
New in ColdFusion MX: 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.)
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.
<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> subjects posted in messages.</h3> <cfset ChangedElement = ListGetAt(temp, 2)> <cfset TempToo = ListSetAt(temp, 2, "I changed this subject", ",")> <ul> <cfloop From = "1" To = "#ListLen(temptoo)#" INDEX = "Counter"> <cfoutput><li>(#Counter#) SUBJECT: #ListGetAt(temptoo, Counter)# </cfoutput> </cfloop> </ul> <p>Note that element 2, "<cfoutput>#changedElement#</cfoutput>", has been altered to "I changed this subject" using ListSetAt.