Systems By Posted June 19, 2006 Share Posted June 19, 2006 Hi everyone. I have a question about the FileReadLine function. Do you know if it is possible to read a text file from the bottom up instead of from the top down? I am writing a backup program and want to be able to make the program delete the oldest backup files. I have all of the names of my backup files created in a cmd window and sent to a text file. A few people told me that it was possible in older versions of AutoIt, but have no idea if it's possible with v3. Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 19, 2006 Share Posted June 19, 2006 (edited) HI, is that really neccessary? You could use _FileReadToArray() and then take Ubound -1 , -2 and so on. This way of course, you read the whole file. (Performance if hufe file :-( ) So long, Mega Edited June 19, 2006 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
jvanegmond Posted June 19, 2006 Share Posted June 19, 2006 #include <File.au3> FileReadLine ( filehandle or "filename" , _FileCountLines(filehandle or "filename") - $number_of_lines_counting_from_bottom ) github.com/jvanegmond Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 19, 2006 Share Posted June 19, 2006 #include <File.au3>FileReadLine ( filehandle or "filename" , _FileCountLines(filehandle or "filename") - $number_of_lines_counting_from_bottom )Hi, _FileCountLines(filehandle or "filename") works only with path not with filehandle! I have to test what is faster. Array, or FCL So long,Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 19, 2006 Moderators Share Posted June 19, 2006 This is like _FileReadToArray(), but without the need to #include <file.au3>$FilePath = 'Path to file here' $FileRead = FileRead($FilePath, FileGetSize($FilePath)) $CreateArray = StringSplit($FileRead, @CR) For $iCount = UBound($CreateArray) - 1 To 1 Step - 1;Start reading backwards ConsoleWrite($CreateArray[$iCount] & @LF) Next 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 More sharing options...
trids Posted June 20, 2006 Share Posted June 20, 2006 I would look for something called a "tail utility". You'll find several commandline equivalents of the original Unix utility via Google. Then you can just call it from your au3 script to produce the summarised logfile. HTH Link to comment Share on other sites More sharing options...
randallc Posted June 20, 2006 Share Posted June 20, 2006 Hi, _FileCountLines(filehandle or "filename") works only with path not with filehandle! I have to test what is faster. Array, or FCL So long, MegaHi, you would only have to call it once; $FileCountLines=FileCountLines( "filename") $number_of_lines_counting_from_bottom=0 while 1 FileReadLine ( filehandle or "filename" , $FileCountLines- $number_of_lines_counting_from_bottom ) if @error then exitloop $number_of_lines_counting_from_bottom+=1 wendetc - would it work?; how quick? I'd be interested in you timing results; not with Arrays for large files. though!? [Even "tail.exe" in microsoft would neeed number of lines first, I think.] Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW 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