CFLib.org – Common Function Library Project

ListLenIncNulls(list[, delimiters])

Last updated September 29, 2003

author

Tom Litt

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns the number of list element in a given list, but counts empty-strings as bona-fide list elements.

Return Values:
Returns a number.

Example:

<cfset TestList = "1|2|3||5">
<cfset TestList2 = "||">
<cfoutput>
List #TestList# has #ListLenIncNulls(TestList,"|")# element(s) when empty strings 
are counted as list elements.<br>
List #TestList2# has #ListLenIncNulls(TestList2,"|")# element(s) when empty strings 
are counted as list elements.
</cfoutput>

Parameters:

Name Description Required
list List to parse. Yes
delimiters List delimiters. Only one character allow. Defaults to a comma. No

Full UDF Source:

/**
 * Length of list including empty elements.
 * 
 * @param list 	 List to parse. (Required)
 * @param delimiters 	 List delimiters. Only one character allow.  Defaults to a comma. (Optional)
 * @return Returns a number. 
 * @author Tom Litt (tom@oxbowbooks.com) 
 * @version 1, September 29, 2003 
 */
function listLenIncNulls(list) {
	var delimiter = ",";
	if(arrayLen(Arguments) GT 1) delimiter = left(arguments[3],1);
	return val(len(list) - len(replace(list,delimiter,"","ALL")) + 1);
}
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