03-24-2009, 08:35 PM
Here is a Script I built to Read a file in and search for version Numbers this should give you an idea of how to search for a string in a file.
Code:
ExpectedVersion = Parameter("ExpectedVersion")
TDMRPT_File = Parameter("File_Path")
Record_Found = 0 ' initialize the "Record_Found" flag...
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile(TDMRPT_File)
Do while MyFile.AtEndofStream <> True
currentLine = MyFile.ReadLine
find_report_record = instr(1,currentLine,"VERSION",1)
Record_Found= Record_Found +find_report_record
If find_report_record > 0 Then
MyVersion = Trim(mid(currentLine,2,50))
If MyVersion <> " " Then
splitstring=split(MyVersion,":")
VersionNumber=replace(splitstring(1)," ","")
Reporter.ReportEvent micPass, "Version Number Exist", "The Version Number was displayed in "&TDMRPT_File&" File "
Valid_Version_Number ExpectedVersion, VersionNumber
Else
Reporter.ReportEvent micFail, "Version Number Exist", "The Version Number was NOT displayed in "&TDMRPT_File&" File "
End If
End If
Loop ' AtEndOfStream
If Record_Found = 0 Then
Reporter.ReportEvent micFail, "Version Number Exist", "The Version Number was NOT displayed in "&TDMRPT_File&" File "
End If