CFLib.org – Common Function Library Project

ListLongestItem(list[, delim])

Last updated September 21, 2004

author

Joseph Flanigan

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns the first occurrence of the longest item in a list.

Return Values:
Returrns a string.

Example:

<cfscript>
myList = "CFLib has the greatest collection of UDF functions.";
writeoutput(ListLongestItem(myList," "));
</cfscript>

Parameters:

Name Description Required
list The list to parse. Yes
delim List delimiter. Defaults to a comma. No

Full UDF Source:

/**
 * Returns the first occurrence of the longest item  in  a list.
 * 
 * @param list 	 The list to parse. (Required)
 * @param delim 	 List delimiter. Defaults to a comma. (Optional)
 * @return Returrns a string. 
 * @author Joseph Flanigan (joseph@switch-box.org) 
 * @version 1, September 21, 2004 
 */
function listLongestItem(list){
	var delim = ","; 
	var item = "";
	var i = 0;
	
	if(arrayLen(arguments) EQ 2) delim = arguments[2];
	for(i = 1 ; i lte listLen(list,delim); i = i + 1 )  {
		if (len(listGetAt(list,i,delim)) gt len(item)) item = listGetAt(list,i,delim); 
	}
	return item; 
}
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