rizwan Posted December 14, 2005 Share Posted December 14, 2005 When i restart my system the file is not appending I am using the following code $file = FileOpen("C:\tools\scripts\Logtime.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit FileWriteLine($file, "Start time is " & _NowTime()) Please advise Link to comment Share on other sites More sharing options...
seandisanti Posted December 14, 2005 Share Posted December 14, 2005 When i restart my system the file is not appending I am using the following code$file = FileOpen("C:\tools\scripts\Logtime.txt", 1); Check if file opened for writing OKIf $file = -1 Then MsgBox(0, "Error", "Unable to open file.") ExitFileWriteLine($file, "Start time is " & _NowTime())Please adviseit doesn't look like you're closing your file, but i don't know if that would cause the issue you're seeing. You may want to just use _FileWriteLog(), you can cut out some of your code that way... Link to comment Share on other sites More sharing options...
rizwan Posted December 15, 2005 Author Share Posted December 15, 2005 it doesn't look like you're closing your file, but i don't know if that would cause the issue you're seeing. You may want to just use _FileWriteLog(), you can cut out some of your code that way...Thanks for your help. actually using the fileclose function worked. I think fileclose should be required after a fileopen. Becuz currently if you goto autoit help it says fileclose is not necessary Link to comment Share on other sites More sharing options...
seandisanti Posted December 15, 2005 Share Posted December 15, 2005 Thanks for your help. actually using the fileclose function worked. I think fileclose should be required after a fileopen. Becuz currently if you goto autoit help it says fileclose is not necessaryyes, the current (beta) text reads:When finished working with a file, call the FileClose function to close the file. Autoit normally closes all files upon termination, but explicitly calling FileClose is still a good idea. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 15, 2005 Moderators Share Posted December 15, 2005 It doesn't say that FileClose "is not necessary", it says for FileWriteLine() "If a filename is given rather than a file handle, the file will be opened and closed during the function call."... But you used FileOpen() with a "handle" ($file = FileOpen()... FileWriteLine($file), so it is neccessary and actually the examples for FileOpen() / FileWriteLine(), both show a FileClose() routine in them. 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. 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