frontmill Posted January 23, 2007 Share Posted January 23, 2007 (edited) My first udf, i needed this for a program and i thought, lets share it with you guys #include-once #include <file.au3> ;=============================================================================== ; ; Function Name: _filereadlastline() ; Description: Returns a certain line from a file by a 0-based index, starting at the end of the file ; Parameter(s): $sFilePath - Path and filename of the file to be read ; $sline - Line to read from the end of the file by a 0-based index ; Requirement(s): AutoIt3 Beta with COM support (post 3.1.1) ; Return Value(s): On Success - Returns the contents of the specified line ; On Failure - Returns 0 and sets @ERROR = 1 ; Author(s): Frontmill ; ;=============================================================================== ; Func _filereadlastline($sFilePath, $iLine) $linecount = _FileCountLines($sFilePath) if @error then SetError(1) Return 0 Else $line = $linecount - $iLine $string = FileReadLine($sFilePath, $line) Return $string EndIf EndFunc Edited January 23, 2007 by frontmill Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted January 23, 2007 Share Posted January 23, 2007 nice work.. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
FitzChivalry Posted January 24, 2007 Share Posted January 24, 2007 yeah, thanks for putting this up... it will be useful :-) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 24, 2007 Moderators Share Posted January 24, 2007 Nice effort... I think I've done this somewhere before... maybe it's in Valuaters wrappers, but it was probably along the lines of:Func _FileGetLastLine($hPath) Local $aSplit = StringSplit(StringStripCR(FileRead($hPath)), @LF) Return $aSplit[$aSplit[0]] EndFunc 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...
frontmill Posted January 26, 2007 Author Share Posted January 26, 2007 Thanks for the comments guys. Link to comment Share on other sites More sharing options...
randallc Posted January 26, 2007 Share Posted January 26, 2007 Hi, If you have, say , a huge log file, it is quicker to use larry's binary read; use my "tailRW.au3" link in signature to see examples; 10s of millisecs instead of a number of secs, say, for a 80Mb file. best, 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