CountLines(text)
Last updated June 3, 2003
Version: 1 | Requires: ColdFusion 5 | 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:
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:
<cfscript>
/**
* 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);
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
10 day(s) ago
Will Belden added
longTime
15 day(s) ago
James Sleeman added
quickSort
25 day(s) ago
Ben Forta added
GetHostAddress
28 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)