Opened 16 years ago

Closed 15 years ago

Last modified 15 years ago

#506 closed Bug (Fixed)


Reported by: Xenobiologist Owned by: Gary
Milestone: Component: AutoIt
Version: Severity: None
Keywords: _FileCountLines Cc:


Same problem as I mentioned before with _FileReadToArray.
The function _FileCountLines should deal all common line-end-chars.

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)
	If StringInStr($sFileContent, @LF) Then
		$aTmp = StringSplit(StringStripCR($sFileContent), @LF)
	ElseIf StringInStr($sFileContent, @CR) Then
		$aTmp = StringSplit($sFileContent, @CR)
		Return SetError(2, 0, 0)
	Return $aTmp[0]
EndFunc   ;==>__FileCountLines

Attachments (0)

Change History (2)

comment:1 Changed 15 years ago by Gary

  • Milestone set to
  • Owner set to Gary
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed in version:

comment:2 Changed 15 years ago by PoorLuzer

This function seems to be buggy.

Discussion carried forward at:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Gary.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.