User Guide
ListAppend 561
ListAppend
Description
Concatenates a list or element to a list.
Returns
A copy of the list, with value appended. If delimiter = "", returns a copy of the list, unchanged.
Category
List functions
Function syntax
ListAppend(list, value [, delimiters ])
See also
ListPrepend, ListInsertAt, ListGetAt, ListLast, ListSetAt
Parameters
Usage
ColdFusion inserts a delimiter character before value.
To add an element to the beginning or end of a list, Macromedia recommends that you do so
with code such as the following, rather than with the
ListAppend or ListPrepend functions:
<cfset MyValue = "another element">
<cfif listLen(myList) is 0>
<cfset myList = MyValue>
<cfelse>
<cfset myList = myList & ", " & MyValue>
</cfif>
The following table shows examples of ListAppend processing:
Example
<h3>ListAppend Example</h3>
<!--- First, query to get some values for our list elements--->
Parameter Description
list A list or a variable that contains one.
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 uses only the first
character.
Statement Output Comment
ListAppend('elem1,elem2', '' )
elem1,elem2, Appended element is empty; delimiter is last
character in list; list length is 2
ListAppend('', 'elem1,elem2' )
elem1,elem2 List length is 2
ListAppend
("one___two", "three",
"___")
"one___two_three" Inserted the first character of delimiters
before "three."