MonsieurOUXX Posted October 20, 2011 Share Posted October 20, 2011 (edited) this is my code : ============= FILE : logging.au3 =========== #Include <Date.au3> func LogMsg($msg) $fileName = "log.txt" $file = FileOpen($fileName, 1) if $file = -1 Then MsgBox(0, "Error", "could not open file " & $fileName) Exit EndIf FileWriteLine($file, _Date_Time_GetSystemTime() & " : " & $msg) FileFlush ($file) FileClose($file) endFunc ============= FILE: mytest.au3 ============= #include "logging.au3" LogMsg("this is a test") As you can see it's very basic and very straightforward. Yet, after I execute "mytest.au3" in SciTE, the file "log.txt" exists but remains desperately empty... I'm on Windows 7 with a Symantec antivirus Edited October 21, 2011 by MonsieurOUXX Link to comment Share on other sites More sharing options...
Valik Posted October 20, 2011 Share Posted October 20, 2011 Basic support question that should have been in General Help and Support (It's now moved there). I don't think you understand what _Date_Time_GetSystemTime() actually returns. Link to comment Share on other sites More sharing options...
sleepydvdr Posted October 21, 2011 Share Posted October 21, 2011 (edited) #include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> LogMsg("this is a test") func LogMsg($msg) $fileName = "log.txt" $file = FileOpen($fileName, 1) if $file = -1 Then MsgBox(0, "Error", "could not open file " & $fileName) Exit EndIf $tDate = _Date_Time_GetSystemTime() FileWriteLine($file, _Date_Time_SystemTimeToDateStr($tDate) & " : " & $msg) FileFlush ($file) FileClose($file) endFunc Edited October 21, 2011 by sleepydvdr #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
MonsieurOUXX Posted October 21, 2011 Author Share Posted October 21, 2011 (edited) Sorry about posting to the wrong forum! I'm pretty much new around here ( I was around some time ago but since then I lost all my good habits ). My apologies again. And both of you are absolutely right: I added "_Date_Time_GetSystemTime()" in a rush at the very end and trusted the name without checking the specs. I was so focused on the file management that I forgot to double-check that, thinking "oh, whatever it outputs I'll have time later to correct it and format it better". Shame on me! Thank you so much, guys/ladies. EDIT: Actually it doesn't change anything, the problem remains.... Edited October 21, 2011 by MonsieurOUXX Link to comment Share on other sites More sharing options...
MonsieurOUXX Posted October 21, 2011 Author Share Posted October 21, 2011 (edited) BUMP. Even with that change, the file remains empty... EDIT : OH WAIT that's actually hilarious (well, from my perspective it is). The issue was simply that since my early tests there were hundreds of blank lines at the beginning of the file. All I had to do was... to scroll down. And if you think I'm retarded, well have a look at Windows 7's theme, where everything is pale gray and where nothing catches the eye (ninja scrollbars...) Edited October 21, 2011 by MonsieurOUXX Link to comment Share on other sites More sharing options...
sleepydvdr Posted October 21, 2011 Share Posted October 21, 2011 BUMP. Even with that change, the file remains empty... The code I gave you works for me. But there is an easier way: #Include <File.au3> _FileWriteLog("Log.txt", "This is a test.") #include <ByteMe.au3> Link to comment Share on other sites More sharing options...
MonsieurOUXX Posted October 21, 2011 Author Share Posted October 21, 2011 (edited) See my update above All my apologies, really. Edited October 21, 2011 by MonsieurOUXX 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