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
#2
Solved: 11 Years, 4 Months ago
Just curious, why can't you just reopen the file in the next script? This approach would also have the advantage of being able to open the file in "append" mode so that you aren't accidentally writing over your previous results:

Script 1 Wrote:'Script 1 (Login script?)
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("C:/QTP.txt", True)
tf.WriteLine("Pass")
tf.Close
Set tf = Nothing
Set fso = Nothing

Script 2 Wrote:'Script 2
Dim ForAppending, fso, tf
ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.OpenTextFile("C:/QTP.txt", ForAppending)
tf.WriteLine("Fail")
tf.Close
Set tf = Nothing
Set fso = Nothing

If you are talking about a test that calls reusable actions and you want to be able to hand the text file between the actions, you could use an environment variable. This works as long as the scripts are calling each other (i.e. clicking run once) since the environment variable only lives for the current test run:

Quote:'Store the text file object in a varaible -->
Environment("ResultsFileObject").Value = tf

'Reuse the text file object somewhere else -->
Environment("ResultsFileObject").WriteLine("Pass")
Reply


Messages In This Thread
RE: How to open a file in one script and write into it in another script - by cdesserich - 10-02-2010, 02:51 AM

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 583 11-05-2023, 03:55 PM
Last Post: lravi4u
  How do you Change Run mode mid script? Caleytown 6 7,194 03-25-2021, 08:27 AM
Last Post: RB26578
  picking different points in UFT using VB Script azjk786 0 1,056 12-14-2020, 09:57 AM
Last Post: azjk786
  script for mouseover rumitkon 2 1,997 02-20-2019, 12:52 AM
Last Post: rumitkon
  Call Stack in QTP Script smitapawar610 0 1,707 12-03-2018, 10:42 AM
Last Post: smitapawar610

Forum Jump:


Users browsing this thread: 1 Guest(s)