Jump to content

New file line count script UDF


Frozenyam
 Share

Recommended Posts

#Include-Once

Func _CountLines (ByRef $File)
   Global $Count = 0

   FileOpen ($File, 0)

   Do
      $Count = $Count + 1
      $CountLine = FileReadLine ($File, $Count)
   Until @Error = -1

   Return $Count - 1
EndFunc

Will count the lines in a file without problems and will output it to a variable.

Use Of Function:

#Include <_CountLines.au3>

$File = "Path\Name.Extention"
$NumOfLines = _CountLines ($File)

_CountLines.au3

Edited by Frozenyam

"... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."

Link to comment
Share on other sites

#Include-Once

Func _CountLines (ByRef $File)
   Global $Count = 0

   FileOpen ($File, 0)

   Do
      $Count = $Count + 1
      $CountLine = FileReadLine ($File, $Count)
   Until @Error = -1

   Return $Count - 1
EndFunc

Will count the lines in a file without problems and will output it to a variable.

Use Of Function:

#Include <_CountLines.au3>

$File = "Path\Name.Extention"
$NumOfLines = _CountLines ($File)

<{POST_SNAPBACK}>

Nice try, but too late. This function was improved by Tylo, and included in the standard UDF. >> File.au3 <<

To improve your code, look the w0uter remarks also.

Link to comment
Share on other sites

  • Developers

Frozenyam PMed me with this update and i mentioned the same, but he claimed that the current version is broken.

Its better to report the BUG when current UDF's don't work then to come up with a modified version, because this gives the original author of a UDF to fix or update the UDF.

:whistle:

Edited by JdeB

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

Frozenyam PMed me with this update and i mentioned the same, but he claimed that the current version is broken.

Its better to report the BUG when current UDF's don't work then to come up with a modified version, because this give the original writer of a UDF to fix or update the UDF.

:whistle:

<{POST_SNAPBACK}>

http://www.autoitscript.com/fileman/users/Josbe/_sforum/smilies/yes.gif I agree completely.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...