Jump to content

Search the Community

Showing results for tags 'Mark I eyeballs required...'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I found the production version of _FileCountLines() improperly handles blank lines at the end of a file. It rarely reports the same number of lines shown in notepad or SciTE. This modified function is 60-70% faster, uses half the memory (allowing it to read larger files and less likely to spit out "memory allocation" errors), and it properly handles blanks lines at the end of a file. Anyone see anything wrong with the following replacement candidate? Thank you. Func _FileCountLines($sFilePath) Local $hFile = FileOpen($sFilePath, $FO_READ) If $hFile = -1 Then Return SetError(1, 0, 0) Local $sFileContent = FileRead($hFile), $aTerminator[2] = ["n", "r"] ; linefeed, carriage return FileClose($hFile) For $x = 0 to 1 StringRegExpReplace($sFileContent, $aTerminator[$x], $aTerminator[$x]) If @extended Then Local $count = @extended If StringRight($sFileContent, 1) <> $aTerminator[$x] Then $count += 1 ExitLoop EndIf Next If Not $count Then If StringLen($sFileContent) Then $count = 1 ; single-line file Else Return SetError(2, 0, 0) ; 0-byte file EndIf EndIf Return $count EndFunc ;==>_FileCountLines Edit: I do see one might save the result of the StringRight() statement, and test that for the single-line/0-byte condition, eliminating the need for the StringLen() statement.
×
×
  • Create New...