listInsertAt
Description
Inserts an element in a list.
Categories
Related
Syntax
ListInsertAt(list, position, value [, delimiters, includeEmptyValues ])
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| 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. | ||
| 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 insert element. The first list position is 1. | ||
| value | An element or a list of elements. |
Returns
A copy
of the list, with value inserted at the specified
position.
Usage
When inserting an element, ColdFusion inserts a delimiter. If delimiters contains more than one delimiter, ColdFusion uses the first delimiter in the string; if delimiters is omitted, ColdFusion uses a comma.
ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.
ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.
Example
<!--- This example shows ListInsertAt ---> <cfquery name = "GetParkInfo" datasource = "cfdocexamples"> SELECT PARKNAME,CITY,STATE FROM PARKS WHERE PARKNAME LIKE 'DE%' </cfquery> <cfset temp = ValueList(GetParkInfo.ParkName)> <cfset insert_at_this_element = ListGetAt(temp, "3", ",")> <cfoutput> The original list: #temp# </cfoutput> <cfset temp2 = ListInsertAt(Temp, "3", "my Inserted Value")>