CFLib.org – Common Function Library Project

ListNew()

Last updated January 12, 2004

author

Samuel Neff

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Converts the passed arguments array to a list and filters blanks. Helpful for creating lists from several values stored in different variables where some may be blank. Since it uses the arguments array as the source data for a list, there is no way to specify delimiters. To use custom delimiters use ListChangeDelims on the returned list.

Return Values:
Returns a list.

Example:

<cfparam name="form.var1" default="">
<cfparam name="form.var2" default="">
<cfparam name="form.var3" default="">

<cfset formValues = ListNew(form.var1, form.var2, form.var3)>

Parameters:

No arguments.

Full UDF Source:

/**
 * Creates a list from the passed arguments, skipping empty elements.
 * 
 * @return Returns a list. 
 * @author Samuel Neff (sam@serndesign.com) 
 * @version 1, January 12, 2004 
 */
function listNew() {
	var arr = arrayNew(1);
	var i = 1;

	for(;i lte arrayLen(arguments);i=i+1) {
		if(arguments[i] neq "") arr[arrayLen(arr)+1] = arguments[i];
	}
	
	return arrayToList(arr);
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson