﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3765	_FileWriteLog	RedZone	Jpm	"$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 [https://www.autoitscript.com/forum/topic/156717-filewritelog-unable-to-append-log-at-beginning-of-file/?do=findComment&comment=1134055 post]

_FileWriteLog help file  [https://www.autoitscript.com/autoit3/docs/libfunctions/_FileWriteLog.htm link]
FileOpen help file [https://www.autoitscript.com/autoit3/docs/functions/FileOpen.htm 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
"	Bug	closed	3.3.15.4	AutoIt	3.3.14.5	None	Fixed	_FileWriteLog	
