View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > ListDeleteAt PreviousNext

ListDeleteAt

Deletes an element from a list.

A copy of the list, without the specified element.

List functions

ListDeleteAt(list, position [, delimiters ])

ListGetAt, ListSetAt, ListLen

Parameter

Description

list

A list or a variable that contains one.

position

A positive integer or a variable that contains one. Position at which to delete element. The first list position is 1.

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 processes each occurrence of each character as a delimiter.

To use this and other functions with the default delimiter (comma), you can code as follows:

<cfset temp2 = ListDeleteAt(temp, "3")>

To specify another delimiter, you code as follows:

<cfset temp2 = ListDeleteAt(temp, "3", ";")>

ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.

<!--- First, query to get some values for our list elements--->
<CFQUERY NAME="GetParkInfo" DATASOURCE="cfsnippets">
   SELECT    PARKNAME,CITY,STATE
   FROM Parks
   WHERE    PARKNAME LIKE 'CHI%'
</CFQUERY>
<CFSET temp = ValueList(GetParkInfo.ParkName)>
<CFSET deleted_element = ListGetAt(temp, "3", ",")>
<cfoutput>
<p>The original list: #temp#
</cfoutput>
<!--- Delete the third element from the list --->
<CFSET temp2 = ListDeleteAt(Temp, "3")>
<cfoutput>
<p>The changed list: #temp2#
<p><I>This list element:<br>#deleted_element#<br> is no longer present 
at position three of the list.</I> </cfoutput>

Contents > CFML Reference > ColdFusion Functions > ListDeleteAt PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


krubo said on May 23, 2005 at 11:37 AM :
Clarification: The original list (#temp# in the example) is not changed.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functib8.htm