Replaces the contents of a list element.
A copy of a list, with a new value assigned to the element at a specified position.
ListSetAt(list, position, value [, delimiters, includeEmptyValues ])
ListDeleteAt, ListGetAt, ListInsertAt; Lists in Data types- Developing guide in the Developing ColdFusion Applications
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.)
Parameter |
Description |
|---|---|
includeEmptyValues |
Optional. Set to yes to include empty values. |
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. Characters that separate list elements. The default value is comma. If this parameter contains more than one character, ColdFusion processes each occurrence of each character as a delimiter. |
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.
<cfscript>
// case 1
myList="Hulk,Superman,Batman,Joker"
// replace Joker with Aquaman at position 4
setAt=ListSetAt(myList,4,"Aquaman")
writeOutput(setAt & "<br/>")
// case 2: using a delimiter
myList1="England|Spain|Germany|France"
// replace Spain with Portugal at position 2
setAt1=ListSetAt(myList1,2,"Portugal","|")
writeOutput(setAt1)
</cfscript>
Output
Hulk,Superman,Batman,Aquaman
England|Portugal|Germany|France
Sign in to your account