frontmill 0 Report post 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 Share this post Link to post Share on other sites
WeMartiansAreFriendly 1 Report post Posted January 23, 2007 nice work.. Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Share this post Link to post Share on other sites
FitzChivalry 0 Report post Posted January 24, 2007 yeah, thanks for putting this up... it will be useful :-) Share this post Link to post Share on other sites
SmOke_N 199 Report post 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. Share this post Link to post Share on other sites
frontmill 0 Report post Posted January 26, 2007 Thanks for the comments guys. Share this post Link to post Share on other sites
randallc 0 Report post 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 Share this post Link to post Share on other sites