Function Reference


_FileWriteToLine

Writes text to a specific line in a file

#include <File.au3>
_FileWriteToLine ( $sFilePath, $iLine, $sText [, $bOverWrite = False] )

Parameters

$sFilePath The file to write to
$iLine The line number to write to
$sText The text to write
$bOverWrite [optional]
    True - will overwrite the old line
    False - (default) will not overwrite

Return Value

Success: 1.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 - File has fewer lines than $iLine
2 - File does not exist
3 - Error when opening file
4 - $iLine is invalid
5 - $iOverWrite is invalid
6 - $sText is invalid

Remarks

If _FileWriteToLine() is called with $iOverWrite as 1 and $sText as "", it will delete the line.

Example

#include <File.au3>

; Example: Write to line 3 of c:\temp\test.txt REPLACING line 3
_FileWriteToLine("c:\temp\test.txt", 3, "my replacement for line 3", True)
; Example: Write to line 3 of c:\temp\test.txt NOT REPLACING line 3
_FileWriteToLine("c:\temp\test.txt", 3, "my insertion", False)