Jump to content

Having trouble using FileOpen


Go to solution Solved by HollyN,

Recommended Posts

I want my script write to a log file. I'm using the following code:

#include <File.au3>

    Local $LogFile = FileOpen(@ScriptDir & "logfilename.log", 1)
    _FileWriteLog($LogFile, "Script started")

The result is as follows:

1. I have an empty file at @ScriptDirlogfilename.log

2. The actual logging is going to a file called "1" in the same directory

This seems like it should be so simple - what am I doing wrong?



Link to comment
Share on other sites

  • Developers

Either use:

Local $LogFile = FileOpen(@ScriptDir & "\logfilename.log", 1)
FileWriteLine($LogFile, "Script started")


#include <File.au3>
_FileWriteLog(@ScriptDir & "\logfilename.log", "Script started")


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
Live for the present,
Dream of the future,
Learn from the past.

Link to comment
Share on other sites

  • Solution


I kept fiddling after I posted and also came up with this:

    Local $LogFile = (@ScriptDir & "logfilename.log")
    FileOpen($LogFile, 1)
    _FileWriteLog($LogFile, "Script started")

I based my first attempt on Example 1 from here:


So I'm not sure why it didn't work. But I'm happy to have something that does work, so no problem. Thanks again.

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

  • Create New...