Jump to content

Filewriteline


rizwan
 Share

Recommended Posts

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

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

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...
Link to comment
Share on other sites

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

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

yes, 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

  • Moderators

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...