Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to open a file in one script and write into it in another script
#5
Solved: 12 Years, 10 Months, 3 Weeks ago
Hi, I've developed some code here. I' working on RFT now... If any syntax's mixed with java, Plz ignore and convert into VBScript.
I'm writing this with out using QTP. just I analyzed and developed... check it once and revert me if you get any issues with this.

Here, you can first create a text file at your desired location and then pass the values required to the function. just call this function and conclude that the passing text has been appended to file.

Code:
public function fncAppendFile(path_of_the_file, updating_text_into_file)
dim fso, fs
dim txtBefore, txtAfter
int intlenBefore, intlenAfter, intlenAppTxtString

intlenAppTxtString = len(updating_text_into_file)

set fso = createobject("Scripting.filesystemobject")

set fs = fso.opentextfile("path_of_the_file", 8)

txtBefore = fs.readall
intlenBefore = len(txtBefore)

fs.writeline(updating_text_into_file)
fs.save

txtAfter = fs.readall
intlenAfter = len(txtAfter)

if (intlenAfter=intlenBefore+intlenAppTxtString) Then

    fncAppendFile = True
    fs.close

else

    fncAppendFile = False
    fs.close

End if

set fso = nothing
set fs = nothing

End function

Dim path_of_the_file, updating_text_into_file

path_of_the_file = " your desired path of the text file"
updating_text_into_file = " The text you want to append to text file is here"

result = fncAppendFile(path_of_the_file, updating_text_into_file)

if(result = True) Then
reporter.reportevent "micpass", "The string is appended to file successfully"
else
reporter.reportevent "micfail", "The string is not appended to file"
end if
Thanks & Regards,
Baba Fakruddin.D
Reply


Messages In This Thread
RE: How to open a file in one script and write into it in another script - by bfakruddin - 10-05-2010, 06:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to send/pass UFT Run Error Dialog as output value to main driver script lravi4u 0 1,108 11-05-2023, 03:55 PM
Last Post: lravi4u
  How do you Change Run mode mid script? Caleytown 6 8,590 03-25-2021, 08:27 AM
Last Post: RB26578
  picking different points in UFT using VB Script azjk786 0 1,440 12-14-2020, 09:57 AM
Last Post: azjk786
  script for mouseover rumitkon 2 2,488 02-20-2019, 12:52 AM
Last Post: rumitkon
  Call Stack in QTP Script smitapawar610 0 2,028 12-03-2018, 10:42 AM
Last Post: smitapawar610

Forum Jump:


Users browsing this thread: 1 Guest(s)