10-02-2010, 02:51 AM
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:
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:
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")