CFLib.org – Common Function Library Project

CountLines(text)

Last updated June 3, 2003

author

Matheus Antonelli

Version: 1 | Requires: CF5 | Library: StrLib

Description:
This function returns the number of lines in a text file loaded into a string. For this UDF, a line is defined as a string ending with Chr(13) or Chr(10). As a reminder, note that list functions only take single character delimiters. When you pass N characters as the delimiter, list functions will use any of the characters as the delimiter.

Return Values:
Returns a number.

Example:

<cfsavecontent variable="foo">
This is Foo.
This is not foo.
Who cares about foo?
</cfsavecontent>

<cfoutput>#CountLines(foo)#</cfoutput>

Parameters:

Name Description Required
text String to parse. Yes

Full UDF Source:

/**
 * This function returns the number of lines in a text file.
 * 
 * @param text 	 String to parse. (Required)
 * @return Returns a number. 
 * @author Matheus Antonelli (matheus_antonelli@ig.com.br) 
 * @version 1, June 3, 2003 
 */
function CountLines(text) {
  var CRLF = Chr(13) & Chr(10);
  return ListLen(text,CRLF);
}
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