File_ReplaceInFile
Description
Section titled “Description”Searches file for specified text-string and replace it with a new string
Syntax
Section titled “Syntax”File_ReplaceInFile(sFile, sSearchString, sReplacementString, bOnlyFirstOccurence, bIgnoreCase) As Boolean
Parameters
Section titled “Parameters”sFile (String)
Section titled “sFile (String)”Source-file
sSearchString (String)
Section titled “sSearchString (String)”String to replace
sReplacementString (String)
Section titled “sReplacementString (String)”New string
bOnlyFirstOccurence (Boolean)
Section titled “bOnlyFirstOccurence (Boolean)”Only first matching string will be replaced. If False, the first match in each line is replaced.
bIgnoreCase (Boolean)
Section titled “bIgnoreCase (Boolean)”Ignore case
Remarks
Section titled “Remarks”- The function replaces at most one match per line. If a line contains the search string more than once, only the first match in that line is replaced. To replace the other matches, call the function again.
- The file must exist and must not be read-only. Otherwise the function returns False.
- The number of replacements is written to the job log.
- The file is read and written as ANSI text. See Text file encoding.
Example
Section titled “Example”If bStatus Then bStatus = File_ReplaceInFile("C:\CapaInstaller.txt", "1999", "2000", False, True)Related functions
Section titled “Related functions”File_AppendToFile File_FindInFile File_GetLineString File_InsertInFile Constants Package Property Variables