Sign in to follow this  
Followers 0
kkurniawan

How to use _FileCountLines function

5 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0