Forum Discussion
tristaanogre
14 years agoEsteemed Contributor
aqString.Find does not return the count of how many instances of the string are found, what it does is find the location in character count of the first instance of the substring. So, in your case, if you open that text file, at character 158, you'll find your first instance of "tabela criada".
To do what you want, you'll need to use aqFile.OpenTextFile to open the file and then use a ReadLn call to read each line into a variable. After reading the line, use aqString.Find to see if your text exists on that line. If it does, increment your count. If it doesn't just move on.
VBScript code would look something like this.
To do what you want, you'll need to use aqFile.OpenTextFile to open the file and then use a ReadLn call to read each line into a variable. After reading the line, use aqString.Find to see if your text exists on that line. If it does, increment your count. If it doesn't just move on.
VBScript code would look something like this.
Sub Procurar
dim LogFile
dim CurrentLine
dim Count
Count = 0
Path = "D:\Scripts\Logs\Oracle\Ora10g"
Set LogFile = aqFile.OpenTextFile(Path&"\1-1.txt", aqFile.faRead, aqFile.ctANSI, false)
aqFile.Create(Path&"\LogsFinais\1-1.txt")
While not LogFile.IsEndOfFile()
s = LogFile.ReadLine()
If (aqString.Find(s, "Tabela criada") > 0) Then
Count = Count + 1
Call aqFile.WriteToTextFile(Path&"\LogsFinais\1-1.txt", "Tabelas criadas!", aqFile.ctANSI)
Call Log.Message("Tabelas criadas!")
Else
Call aqFile.WriteToTextFile(Path&"\LogsFinais\1-1.txt", "Tabelas não criadas!", aqFile.ctANSI)
End If
WEnd
Call Log.Message("No of Tabelas criadas = " + VarToStr(Count))
End Sub