Sign in to follow this  
Followers 0
ghettochild

funcing stupid piece of script

4 posts in this topic

I need help using:

Function: _FileCountLines( $sFilePath )

It was in the help file. Can someone make it read a file and report back in msgbox? just so i can get the gist of it.

i keep trying something to the effect of:

$linecount = Function: _FileCountLines( $sFilePath )

yes, yes i do know that the $sfilepath is default (in my script the file path is perfect.)

Share this post


Link to post
Share on other sites



_filecountlines is a user-defined function (UDF) that counts the number of lines in a file. The syntax would be something like:

$linecount =  _FileCountLines( $sFilePath )

Where $sFilePath is the name of the file you wish to analyze.

But you'll net to include this line somewhere on the top of your script:

#include <file.au3>

You can try this:

#include <file.au3>
$A = _filecountlines("mytextfile.txt")
MsgBox(0,"","The file has " & $A & "lines.")

Hope that helped. :D

Share this post


Link to post
Share on other sites

if you want to do it yourself, lines are simply @CRLF or @CR, or @LF. if it is a normal windows text file, you can simply count the @CR in a file.

$file=FileRead("c:\myfile.txt",Filegetsize("c:\myfile.txt"))
$x=Stringsplit($file,@CR)
msgbox(1,"Line count","There are " & $x[0] & " lines.")

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Wouldn't the last line not have a @CR so it would be the total lines + 1?

red

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