﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
506	_FileCountLines	Xenobiologist	Gary	"Same problem as I mentioned before with _FileReadToArray.
The function _FileCountLines should deal all common line-end-chars.
LF, CR, CRLF.

I changed it to this:


{{{
; #FUNCTION# ====================================================================================================================
; Name...........: _FileCountLines
; Description ...: Returns the number of lines in the specified file.
; Syntax.........: _FileCountLines($sFilePath)
; Parameters ....: $sFilePath - Path and filename of the file to be read
; Return values .: Success - Returns number of lines in the file.
;                  Failure - Returns a 0
;                  @Error  - 0 = No error.
;                  |1 = File cannot be opened or found.
;                  |2 = Unable to Split the file
; Author ........: Tylo <tylo at start dot no>
; Modified.......: Xenobiologist
; Remarks .......: It does not count a final @LF as a line.
; Related .......:
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================

Func __FileCountLines($sFilePath)
	Local $hFile, $sFileContent, $aTmp
	$hFile = FileOpen($sFilePath, 0)
	If $hFile = -1 Then Return SetError(1, 0, 0)
	$sFileContent = StringStripWS(FileRead($hFile, FileGetSize($sFilePath)), 2)
	FileClose($hFile)
	If StringInStr($sFileContent, @LF) Then
		$aTmp = StringSplit(StringStripCR($sFileContent), @LF)
	ElseIf StringInStr($sFileContent, @CR) Then
		$aTmp = StringSplit($sFileContent, @CR)
	Else
		Return SetError(2, 0, 0)
	EndIf
	Return $aTmp[0]
EndFunc   ;==>__FileCountLines
}}}
"	Bug	closed	3.2.13.8	AutoIt	3.2.13.7	None	Fixed	_FileCountLines	
