CountLines(text)
Last updated June 03, 2003
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);
}
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