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);
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson