bourny Posted June 5, 2008 Share Posted June 5, 2008 I am looking to improve my script log file function. This function is quite basic and simply does the following $Logfile = "Testscript.log" $WorkingLogFile = FileOpen ("c:\YMpkg\Logs\" & $LogFile , 2) I then send messages to the log file in the following way. FileWriteLine($WorkingLogFile, $Time) FileWriteLine($WorkingLogFile, $date) FileWriteLine($WorkingLogFile, "....Starting installation function") Etc ... The issue with this is if the script falls over and terminates or the user / OS kills the process the log file will be empty. I can get around this by writing a function that opens and closes the logfile for each message but I fiure this isnt very efficient and there must be a better way to do this... Any ideas appreciated.... Link to comment Share on other sites More sharing options...
sandin Posted June 5, 2008 Share Posted June 5, 2008 try this: $location = FileOpenDialog("select file", "", "Text files (*.txt)") Local $i = 0 While 1 $i += 1 FileWrite($location, "Line: " & $i & @CRLF) Sleep(1000) WEnd compile it and run it, while it's working terminate the prog. via Task Manager, and see, the added lines should stay even if the task is being terminated Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
bourny Posted June 5, 2008 Author Share Posted June 5, 2008 Thanks ... Works a treat... Give yourself a pat on the back and I will slp myself for not finding this in the help file ... Many Thanks 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