Jump to content

How to use _FileCountLines function


Recommended Posts

Hi there,

I want to use _FileCountLines to count how many lines in the file and show the number of the lines with the message box. I looked at AutoIt help file and found _FileCountLines function, but when I tried the example, nothing happens. Did I miss something?

#include<file.au3>

$CountLines = _FileCountLines("C:\error.log")

MsgBox(64, "Error log recordcount", "There are " & $CountLines & " in the error.log.")

Exit

Thanks.

Link to comment
Share on other sites

  • Moderators

Is there actually an 'error.log' file at that path location?

Edit:

Also, are you using the beta 'include'? I think that UDF is in the beta #include <file.au3>

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Yes, there is an error.log under C:. I changed the script and I got error message "Unknown Function for line 2"

$sFilePath = FileOpen("C:\error.log", 0)

$CountLines = _FileCountLines($sFilePath )

MsgBox(64, "Error log recordcount", "There are " & $CountLines & " in the error.log.")

Exit

Thanks.

Link to comment
Share on other sites

Use it like this :lmao: with AutoIt Beta !!

#include <File.au3>

$Importfile="c:\error.log"

$file=FileOpen($ImportFile,0) ;for read

$CountLines = _FileCountLines($ImportFile)

MsgBox(64, "Error log recordcount", "There are " & $CountLines & " in the error.log.")

FileClose($file)

Edited by Micha1405
Link to comment
Share on other sites

  • Developers

Use it like this :lmao: with AutoIt Beta !!

#include <File.au3>

$Importfile="c:\error.log"

$file=FileOpen($ImportFile,0) ;for read

$CountLines = _FileCountLines($ImportFile)

MsgBox(64, "Error log recordcount", "There are " & $CountLines & " in the error.log.")

FileClose($file)

You don't need the FileOpen() and FileCLose() lines... _FileCountLines() will handle that.... ;)

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

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...