Tuesday, August 26, 2008

AHK - GetFileLines()

This is a simple function that retrieves the total number of lines in a text file, without using any loops. I tested it on a file with about 1200 lines and it took less than 20ms.

GetFileLines(ByRef OutputVar,FileLocation) {
FileRead, File, % FileLocation
StringSplit, Lines, File, `n
OutputVar := Lines0
}
Example use
GetFileLines(TotalLines,"YourTextFile.txt")
MsgBox YourTextFile.txt has %TotalLines% lines!
Forum Post

No comments: