Jump to content

File lines

Recommended Posts

There's no easier way than to read the whole file and count the lines while reading... so there is no sense in putting this on the wishlist. Of course this would be a bit faster when it was builtin but I don't think the small difference will matter.

Func FileCountLines($File)
    Local $FH, $Lines = -1
    $FH = FileOpen($File, 0)
    If $FH = -1 Then
        Return 0
    While Not @error
        $Lines = $Lines + 1
    Return $Lines
EndFunc  ;==>FileCountLines
Link to comment
Share on other sites


I Think that technically it's not possible to do it another way :ph34r:

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

mmm... but it could be a built in function... if (like me), you have written in languages (if you want to call it that) like the mIRC scripting language, you know of the $lines() identifier, which will give you the amount of lines in a file.

Sitting comfortably behind the code.

Link to comment
Share on other sites

But the problem is, if it's built in, it'll look identical (Except using C's syntax). Something that simple, surely, can be left up to the script-writer to write. Besides, there is a function in the standard library called _FileCountLInes which already does this (I think this is included in the latest stable build, as well).

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

  • Recently Browsing   0 members

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