kredzio Posted September 27, 2014 Posted September 27, 2014 (edited) Hello, How i can read file line by line, when file is changing all the time and are added new lines to it at the end. I must read each new line. This must look something like this. - I open file and read all - wait for next line - if next line has been added so i read it - and we loop to wait for next line I think i can't open this file all the time when i want read line because file have 12MB and 2-5 lines are added in each second Edited September 27, 2014 by kredzio
kylomas Posted September 27, 2014 Posted September 27, 2014 (edited) kredzio, You can try something like this... expandcollapse popup#include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <date.au3> #include <array.au3> #AutoIt3Wrapper_Add_Constants=n local $gui010 = guicreate('') local $aSize = wingetclientsize($gui010) local $edt010 = guictrlcreateedit('',10,20,$aSize[0]-20,$aSize[1]-50,bitor($es_readonly,$ws_hscroll,$ws_vscroll)) GUICtrlSetLimit($edt010,999999999) guisetstate() adlibregister('_log_reader',2000) while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd func _log_reader() local static $FilePos = 0 local $fl = fileopen(@scriptdir & '\file.txt') if $fl = -1 then exit msgbox(0,'','File open failed') if not filesetpos($fl,$FilePos,0) then exit msgbox(0,'ERROR','FileSetPos failed') local $sTmp = fileread($fl) $FilePos = filegetpos($fl) fileclose($fl) guictrlsetdata($edt010,_now() & ' ' & 'Data Added from Log file:' & @crlf & $sTmp,1) endfunc 1st iteration will read the entire file. Subsequent iterations will read records added since last iteration. Iterations are controlled by the adlib timer. kylomas edit: concurrent access may cause unpredictable results, etc, etc... Edited September 27, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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