igorm Posted October 31, 2008 Share Posted October 31, 2008 (edited) Hi, I want to report bug with latest AutoIt beta. When only one line is present in file, _FileCountLines will return 0 instead of 1. I really don't have time to go with bug report system, so I'm reporting here. Cheers I edited function in latest beta so it works for me. I use old solution from latest stable version and solution from latest beta. Here it is: Func _FileCountLines($sFilePath) Local $N = FileGetSize($sFilePath) - 1 ;~ If @error Or $N = -1 Then Return 0 ;~ Return StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1 Local $hFile, $sFileContent, $aTmp $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then Return SetError(1, 0, 0) $sFileContent = StringStripWS(FileRead($hFile), 2) FileClose($hFile) If StringInStr($sFileContent, @CR) Then $aTmp = StringSplit(StringStripCR($sFileContent), @LF) ElseIf StringInStr($sFileContent, @CR) Then $aTmp = StringSplit($sFileContent, @CR) ElseIf Not $sFileContent = "" Then $aTmp=StringLen(StringAddCR(FileRead($sFilePath, $N))) - $N + 1 Else Return SetError(2, 0, 0) EndIf If IsArray($aTmp) Then Return $aTmp[0] Else Return $aTmp EndIf EndFunc ;==>_FileCountLines Edited October 31, 2008 by igorm Office 2000/XP/2003/2007 Slipstreamer Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 31, 2008 Share Posted October 31, 2008 (edited) Confirmed issue is not present with 3.2.12.1 but is present with 3.2.13.9. Demo script: #include <File.au3> $sFile = _TempFile() $hFile = FileOpen($sFile, 2) FileWrite($hFile, "One line of text.") FileClose($hFile) ConsoleWrite("Count = " & _FileCountLines($sFile) & @LF) FileDelete($sFile) Terminating newline character doesn't matter as the result is the same with FileWriteLine() vice FileWrite(). Edited October 31, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GaryFrost Posted November 1, 2008 Share Posted November 1, 2008 (edited) Try: Func _FileCountLines($sFilePath) Local $hFile, $sFileContent, $aTmp $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then Return SetError(1, 0, 0) $sFileContent = StringStripWS(FileRead($hFile), 2) FileClose($hFile) If StringInStr($sFileContent, @LF) Then $aTmp = StringSplit(StringStripCR($sFileContent), @LF) ElseIf StringInStr($sFileContent, @CR) Then $aTmp = StringSplit($sFileContent, @CR) Else If StringLen($sFileContent) Then Return 1 Else Return SetError(2, 0, 0) EndIf EndIf Return $aTmp[0] EndFunc ;==>_FileCountLines If you don't have time to go into trac to report it, maybe I don't have time to fix it. Edited November 1, 2008 by GaryFrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
igorm Posted November 1, 2008 Author Share Posted November 1, 2008 If you don't have time to go into trac to report it, maybe I don't have time to fix it.I don't need your attitude. I have one of my own (bad attitude.)BTW, thanks for new function. To bad you don't have time.Cheers Office 2000/XP/2003/2007 Slipstreamer Link to comment Share on other sites More sharing options...
Developers Jos Posted November 1, 2008 Developers Share Posted November 1, 2008 BTW, thanks for new function. To bad you don't have time.Cheers Doubt this is considered funny. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
igorm Posted November 1, 2008 Author Share Posted November 1, 2008 Doubt this is considered funny.You can consider what ever you want. I really appreciate what AutoIt developers do, but if I don't have the time to go with bug system, that does not mean that some developer should complain. Nobody force him to develop. What he wrote in his post sounded to me like he is complaining. I'm sorry if somebody is offended with my posts, that was not my intention.Cheers Office 2000/XP/2003/2007 Slipstreamer Link to comment Share on other sites More sharing options...
Developers Jos Posted November 1, 2008 Developers Share Posted November 1, 2008 (edited) You can consider what ever you want. I really appreciate what AutoIt developers do, but if I don't have the time to go with bug system, that does not mean that some developer should complain. Nobody force him to develop. What he wrote in his post sounded to me like he is complaining. I'm sorry if somebody is offended with my posts, that was not my intention.Cheers You sure have an arrogant approach here, but I am not going to spent more time on you as I don't care to much for people that want things to happen but "have no time" when they have to do something themselves.Jos Edited November 1, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
igorm Posted November 1, 2008 Author Share Posted November 1, 2008 You sure have an arrogant approach here, but I am not going to spent more time on you as I don't care to much for people that want things to happen but "have no time" when they have to do something themselves.JosI don't see your point here. I don't want anything here to happen and I do things which I need myself. I even suggested temporary solution. What in your opinion do I need to do here?Cheers Office 2000/XP/2003/2007 Slipstreamer Link to comment Share on other sites More sharing options...
Josbe Posted November 1, 2008 Share Posted November 1, 2008 I don't see your point here. I don't want anything here to happen and I do things which I need myself. I even suggested temporary solution. What in your opinion do I need to do here?Cheers Wasn't more easy/fast a report in trac than 3 replies in this thread? Suggestion: Next time, better use the Trac if you want benefit to Devs/community. Isn't obligatory, simply it's a better procedure. AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
igorm Posted November 1, 2008 Author Share Posted November 1, 2008 Wasn't more easy/fast a report in trac than 3 replies in this thread? Suggestion: Next time, better use the Trac if you want benefit to Devs/community. Isn't obligatory, simply it's a better procedure.I agree. Now I have more time, but in the time I reported I was in hurry, so I just reported it so I don't forget it.Cheers Office 2000/XP/2003/2007 Slipstreamer Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now