File_FindInFile
Description
Section titled “Description”Search for specified string in a file.
Syntax
Section titled “Syntax”File_FindInFile(sFile, sSearchString, bIgnoreCase, bMustExist) As Boolean
Parameters
Section titled “Parameters”sFile (String)
Section titled “sFile (String)”Filename
sSearchString (String)
Section titled “sSearchString (String)”String to find
bIgnoreCase (Boolean)
Section titled “bIgnoreCase (Boolean)”Ignore case
bMustExist (Boolean)
Section titled “bMustExist (Boolean)”String must exist
Return value
Section titled “Return value”If sSearchString is found, gbValue is True, the numbers of the matching lines are returned in gaValue (the first line in the file is line 1), giValue contains the number of matching lines, and gsValue contains the content of the last matching line.
The function returns False if sSearchString isn’t found and bMustExist is True.
Remarks
Section titled “Remarks”- The file must exist. If it doesn’t, the function returns False, whatever the value of bMustExist.
- The file is read as ANSI text. See Text file encoding.
Example
Section titled “Example”If bStatus Then bStatus = File_FindInFile("C:\CapaInstaller.txt", "CapaInstaller", True, True)If bStatus And gbValue Then For index = LBound(gaValue) to UBound(gaValue) bStatus = Job_WriteLog("Custom", "String found in line: " & gaValue(index), bStatus, True) NextEnd IfRelated functions
Section titled “Related functions”File_AppendToFile File_GetLineString File_InsertInFile Constants Package Property Variables