galan2015, You have discovered a bug in _FileWriteToLine - when it was rewritten the check for an error in the $bOverWrite parameter was badly formatted and so it fails regardless of the setting. I will fix it for the next release but you can use this modified function in the meantime: #include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ComboConstants.au3>
#include <File.au3>
$sFilePath = @ScriptDir & '\ostatniedane.txt'
; Simulate creation of the file
FileDelete($sFilePath)
FileWrite($sFilePath, "Fixed" & @CRLF & "Replaceable")
$sCheck = FileRead($sFilePath)
MsgBox($MB_SYSTEMMODAL, "Content", $sCheck)
$hGUI = GUICreate("Test", 500, 500)
$Combo5 = GUICtrlCreateCombo("", 184, 98, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo5, "http://craigslist.org|http://reddit.com|http://google.com|http://gmail.com")
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Combo5
ZapisywanieMiejscaProgramu()
EndSwitch
WEnd
Func ZapisywanieMiejscaProgramu()
Switch GUICtrlRead($Combo5)
Case 'http://craigslist.org'
_FileWriteToLine_Mod($sFilePath, 2, '1', True)
Case 'http://reddit.com'
_FileWriteToLine_Mod($sFilePath, 2, '2', True)
Case 'http://google.com'
_FileWriteToLine_Mod($sFilePath, 2, '3', True)
EndSwitch
$sCheck = FileRead($sFilePath)
MsgBox($MB_SYSTEMMODAL, "Content", $sCheck)
EndFunc ;==>ZapisywanieMiejscaProgramu
Func _FileWriteToLine_Mod($sFilePath, $iLine, $sText, $bOverWrite = False)
If $iLine <= 0 Then Return SetError(4, 0, 0)
If Not IsString($sText) Then
$sText = String($sText)
If $sText = "" Then Return SetError(6, 0, 0)
EndIf
If $bOverWrite = Default Then $bOverWrite = False
If Not (IsBool($bOverWrite) Or $bOverWrite = 0 Or $bOverWrite = 1) Then Return SetError(5, 0, 0) ; For old versions.
If Not FileExists($sFilePath) Then Return SetError(2, 0, 0)
Local $aArray = FileReadToArray($sFilePath)
Local $iUBound = UBound($aArray) - 1
If ($iUBound + 1) < $iLine Then Return SetError(1, 0, 0)
Local $hFileOpen = FileOpen($sFilePath, FileGetEncoding($sFilePath) + $FO_OVERWRITE)
If $hFileOpen = -1 Then Return SetError(3, 0, 0)
Local $sData = ""
$iLine -= 1 ; Now the array is 0-based, so reduce the line number by 1.
For $i = 0 To $iUBound
If $i = $iLine Then
If $bOverWrite Then
If $sText Then $sData &= $sText & @CRLF
Else
$sData &= $sText & @CRLF & $aArray[$i] & @CRLF
EndIf
ElseIf $i < $iUBound Then
$sData &= $aArray[$i] & @CRLF
ElseIf $i = $iUBound Then
$sData &= $aArray[$i]
EndIf
Next
FileWrite($hFileOpen, $sData)
FileClose($hFileOpen)
Return 1
EndFunc ;==>_FileWriteToLine
That works for me. M23 Edit: Fixed.