Opened 6 years ago
Closed 6 years ago
#3765 closed Bug (Fixed)
_FileWriteLog
| Reported by: | RedZone | Owned by: | J-Paul Mesnage |
|---|---|---|---|
| Milestone: | 3.3.15.4 | Component: | AutoIt |
| Version: | 3.3.14.5 | Severity: | None |
| Keywords: | _FileWriteLog | Cc: |
Description
$iFlag value does not work when $sLogPath = a file handle returned from FileOpen().
It appears that FileOpen()$mode=1$FO_APPEND (1) = Write mode (append to end of file) overrides _FileWriteLog $iFlag value.
In reference to this post
_FileWriteLog help file link
FileOpen help file link
Example:
#include <File.au3>
$hTest = fileopen("C:\temp\test.log", 1)
$sTestPath = "C:\temp\test.log"
;Test with handle
_FileWriteLog($hTest, "First Message")
_FileWriteLog($hTest, "Message at the End", -1)
_FileWriteLog($hTest, "Message at the Top", 1)
ShellExecute($sTestPath)
FileClose($hTest)
Result:
2020-06-07 10:54:16 : First Message
2020-06-07 10:54:16 : Message at the End
2020-06-07 10:54:16 : Message at the Top
#include <File.au3>
$hTest = fileopen("C:\temp\test.log", 1)
$sTestPath = "C:\temp\test.log"
;Test with handle
_FileWriteLog($sTestPath, "First Message")
_FileWriteLog($sTestPath, "Message at the End", -1)
_FileWriteLog($sTestPath, "Message at the Top", 1)
ShellExecute($sTestPath)
FileClose($hTest)
Result:
2020-06-07 10:55:58 : Message at the Top
2020-06-07 10:55:58 : First Message
2020-06-07 10:55:58 : Message at the End
Attachments (0)
Change History (2)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
| Milestone: | → 3.3.15.4 |
|---|---|
| Owner: | set to |
| Resolution: | → Fixed |
| Status: | new → closed |
Fixed by revision [12351] in version: 3.3.15.4

As when using Handle it will be needed to override the opening mode,
I prefer to change the doc to explain that with handle the $iFlag is ignored and so only apending will occurs