HimanshuG Posted August 15, 2011 Share Posted August 15, 2011 I am new to AutoIt and would like to know if there is any function which can return the number of lines in a file. I intend to go through a file and do something for each line of code as this of course requires a loop I want to make sure that the program only goes through the file till the end. If there is a way to find out if the file has ended it will also do. Himanshu Goel Link to comment Share on other sites More sharing options...
UEZ Posted August 15, 2011 Share Posted August 15, 2011 Look in the help file for _FileCountLinesBr,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
hannes08 Posted August 15, 2011 Share Posted August 15, 2011 Well, technically _FileCountLines loops through the whole file, if you intend to use the file late on, you could use _FileReadToArray(), then you'll have both: The number of read lines in array element 0, and the contents of the file from array element 1 onward. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
ProgAndy Posted August 15, 2011 Share Posted August 15, 2011 (edited) If you don't want to have all lines in memory, you'll have to use a loop that stops when no more lines are available: $hFile = FileOpen("myfile.txt") $linecount = 0 $line = FileReadLine($hFile) while not @error $linecount += 1 ... do something with $line $line = FileReadLine($hFile) wend FileClose($hFile) Edited August 15, 2011 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now