Hey folks,
I tried to write function for retrive value from notepad and get particular data from it.
Precondition: Notepad line format should be same with some pattern like comma sepearted.
call opennotepad()
public function opennotepad()
Dim objFSO, fileName, objFile, strContents, str, position
Set objFSO = CreateObject("Scripting.FileSystemObject")
fileName = "D:\Trupti \folder\Automation\filename.txt"
Set objFile = objFSO.OpenTextFile(fileName,1,true)
reporter.ReportEvent micPass,"File open","File open successfully"
strContents1 = objFile.ReadLine
For I = 0 to 13 '13 is line count, we can write variable if it dynemic
strContents = objFile.ReadLine
DataTable.SetCurrentRow(I)
Call StoringValues(strContents)
field1=Trim(locfield1)
field2=Trim(locfield2)
Next
objFile.Close
Set objFile = nothing
Set objFSO = nothing
End Function
Public Function StoringValues(strContents)
locfield1=mid(strContents,2,22) ' in mid function-strcontent is string, 2 is start value, and 22 is upto 22 length of char data will retrive
localfield2=mid(strContents,87,5)
Endfunction
I tried to write function for retrive value from notepad and get particular data from it.
Precondition: Notepad line format should be same with some pattern like comma sepearted.
call opennotepad()
public function opennotepad()
Dim objFSO, fileName, objFile, strContents, str, position
Set objFSO = CreateObject("Scripting.FileSystemObject")
fileName = "D:\Trupti \folder\Automation\filename.txt"
Set objFile = objFSO.OpenTextFile(fileName,1,true)
reporter.ReportEvent micPass,"File open","File open successfully"
strContents1 = objFile.ReadLine
For I = 0 to 13 '13 is line count, we can write variable if it dynemic
strContents = objFile.ReadLine
DataTable.SetCurrentRow(I)
Call StoringValues(strContents)
field1=Trim(locfield1)
field2=Trim(locfield2)
Next
objFile.Close
Set objFile = nothing
Set objFSO = nothing
End Function
Public Function StoringValues(strContents)
locfield1=mid(strContents,2,22) ' in mid function-strcontent is string, 2 is start value, and 22 is upto 22 length of char data will retrive
localfield2=mid(strContents,87,5)
Endfunction