WilliamWhite Posted January 9, 2010 Posted January 9, 2010 (edited) Hello, as many other i want a log file. I started with opening a notepad and sending text to it, which worked perfectly, but wasnt what i wanted. So i found FileWriteLine. But this one confused me.......When entered in the program it wouldnt do its job. There were simply hardly any entries. So i decided to make next script as test. #include <Date.au3> WriteToLog2("Started Sequence") Func WriteToLog2($Message) $logfile2=FileOpen("logfile2.log", 1) $tCur = _Date_Time_GetLocalTime() If $logfile2 = 0 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine( $logfile2, _Date_Time_SystemTimeToDateTimeStr($tCur) & " " & $message) FileClose("logfile2.log") EndFunc WriteToLog2("Hallo World") WriteToLog2("En dit is de tweede regel") ;sleep (400000) And this works perfect. I embedded this one in the big program....no go again So to try to find out what happens i added the sleep(40000). Result: It seems that if the programm doesnt quit right after the write statement it wont write at all... With sleep>>no writelines in my log.....without sleep>>>>they are there.. What do I wrong? regards, William Edited January 9, 2010 by WilliamWhite
WilliamWhite Posted January 9, 2010 Author Posted January 9, 2010 MMM, still be interested to know the behaviour of this function...But found a smiliar func that works fine. _FileWriteLog So I stick to that for my purposes. regards, William
madScientist Posted January 9, 2010 Posted January 9, 2010 (edited) I use it like this $file=FileOpen("log.txt",1) if($file<>-1)then FileWriteLine($file,$logtext) FileClose($file) endif And never had any problems. I also have an else in there wich sleeps for 10 miliseconds and tries to re-open the file depending on other options.. ---Edit1 You have if $fileHandler=0 In the autoit help file it says that on failure it returns -1, not zero Edited January 9, 2010 by madScientist
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