File_InsertInFile
Description
Section titled “Description”Inserts string in file
Syntax
Section titled “Syntax”File_InsertInFile(sFile, sSearchString, sInsertString, bOnlyFirstOccurence, bIgnoreCase, sMode) As Boolean
Parameters
Section titled “Parameters”sFile (String)
Section titled “sFile (String)”Filename
sSearchString (String)
Section titled “sSearchString (String)”Pre-string to find. A line matches when it contains this string anywhere in the line. Not used with the modes TOP and BOTTOM.
sInsertString (String)
Section titled “sInsertString (String)”String to insert before or after pre-string. It’s inserted as a separate line.
bOnlyFirstOccurence (Boolean)
Section titled “bOnlyFirstOccurence (Boolean)”Insert by first occurrence (TRUE or FALSE)
bIgnoreCase (Boolean)
Section titled “bIgnoreCase (Boolean)”Ignore case (TRUE or FALSE)
sMode (String)
Section titled “sMode (String)”Insert-mode. sMode can be one of following values (not case-sensitive):
| Value | Result |
|---|---|
TOP |
Inserts the string as the first line of the file. |
BOTTOM |
Inserts the string as the last line of the file. |
BEFORE |
Inserts the string on a new line before each matching line. |
AFTER |
Inserts the string on a new line after each matching line. |
Remarks
Section titled “Remarks”- The file must exist and must not be read-only. Otherwise the function returns False.
- The file is read and written as ANSI text. See Text file encoding.
Example
Section titled “Example”If bStatus Then bStatus = File_InsertInFile(gsWindowsDir & "\WIN.BAK", "", gsWindowsDir & "\WIN.BAK was created " & Now, True, True, "TOP")Related functions
Section titled “Related functions”File_AppendToFile File_FindInFile File_GetLineString Constants Package Property Variables