karanth Absent Member.
Absent Member.
190 views

append data to the text file after each iiteration

Jump to solution
Hi All,

Im very greatful for your help on my last post.
I have another issue here.

I have 800 testc ases. Every time i run it, i need to update the result to the file.

Code:
Const ForAppending = 8
Set objTextFile = objFSO.OpenTextFile (strDirectory & strFile, ForAppending, True)
objTextFile.WriteLine(strTcName&" ")
objTextFile.Close

Here for me its always appending the last result. 😞

can anyone help.

Thanks all.
0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.. Babji Absent Member..
Absent Member..

Re: append data to the text file after each iiteration

Jump to solution
Const ForAppending = 8
Dim strFile, strDirectory
strDirectory = "Path of the Directory"
strFile = "Text file Name"


' For eg, you're test cases are calling from DataTable

RC=Datatable.getsheet("SheetID").getrowcount 'Your TC Count (800)
CC=Datatable.getsheet("SheetID").getparametercount

For i=1 to RC
func_Name = Datatable.value("Func_Name",dtGlobalSheet)
Execute "Ret=Cstr(func_Name)" ' Here function returns a value. Even you can append return value or "You mentioned strTcName"

strTcName = strTCName & "is " & Ret 'It appends your TC pass or fail
Call func_Append(strDirectory,strFile,ForAppending,strTcName)
Next


Function func_Append(strDirectory,strFile,ForAppending,strTcName)
Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, ForAppending, True)
objTextFile.WriteLine(strTcName&" ")
objTextFile.Save
objTextFile.Close
End Function

View solution in original post

0 Likes
4 Replies
Knowledge Partner
Knowledge Partner

Re: append data to the text file after each iiteration

Jump to solution
Thus is probably due to where you are calling the function from.

You need to call it at the end of each test case or iteration I think.

Mark Smith.
0 Likes
karanth Absent Member.
Absent Member.

Re: append data to the text file after each iiteration

Jump to solution
Yes i am calling at the end of each iteration.
0 Likes
Highlighted
Absent Member.. Babji Absent Member..
Absent Member..

Re: append data to the text file after each iiteration

Jump to solution
Const ForAppending = 8
Dim strFile, strDirectory
strDirectory = "Path of the Directory"
strFile = "Text file Name"


' For eg, you're test cases are calling from DataTable

RC=Datatable.getsheet("SheetID").getrowcount 'Your TC Count (800)
CC=Datatable.getsheet("SheetID").getparametercount

For i=1 to RC
func_Name = Datatable.value("Func_Name",dtGlobalSheet)
Execute "Ret=Cstr(func_Name)" ' Here function returns a value. Even you can append return value or "You mentioned strTcName"

strTcName = strTCName & "is " & Ret 'It appends your TC pass or fail
Call func_Append(strDirectory,strFile,ForAppending,strTcName)
Next


Function func_Append(strDirectory,strFile,ForAppending,strTcName)
Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, ForAppending, True)
objTextFile.WriteLine(strTcName&" ")
objTextFile.Save
objTextFile.Close
End Function

View solution in original post

0 Likes
karanth Absent Member.
Absent Member.

Re: append data to the text file after each iiteration

Jump to solution
Thanks, i worked on it and have the issue fixed.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.