Whatever message this page gives is out now! Go check it out!

ListSetAt

Last update:
May 18, 2026

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

Function syntax

ListSetAt(list, position, value [, delimiters, includeEmptyValues ])

See also

ListDeleteAtListGetAtListInsertAtLists in Data types- Developing guide in the Developing ColdFusion Applications

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

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.

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

<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

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page