The following are some file operations which are useful for debugging. The following examples can be found in the FileOperationForDebugging.vbs file located in the <QuickTest installation folder>\CodeSamplesPlus folder.
' Creates a specified file and returns a TextStream object that can be used to read from or write to the file.
' Set f = CreateFile("d:\emp\beenhere.txt", True)
Function CreateFile(sFilename, bOverwrite)
Set fso = CreateObject("Scripting.FileSystemObject")
Set CreateFile = fso.CreateTextFile(sFilename, bOverwrite)
' Opens a specified file and returns a TextStream object that can be used to read from, write to, or append to the file.
' iomode: 1 - ForReading, 2 - ForWriting, 8 - ForAppending
' Set f = OpenFile("d:\emp\beenhere.txt", 2, True)
Function OpenFile(sFilename, iomode, create)
Set fso = CreateObject("Scripting.FileSystemObject")
Set OpenFile = fso.OpenTextFile(sFilename, iomode, create)
' AppendToFile "d:\emp\beenhere.txt", Now
Function AppendToFile(sFilename, sLine)
sFilename = Environment("SystemTempDir") & "\QTDebug.txt"
Set f = OpenFile(sFilename, ForAppending, True)
' Destroys the current content of the file .
' WriteToFile "d:\emp\beenhere.txt", Now
Function WriteToFile(sFilename, sLine)
sFilename = Environment("SystemTempDir") & "\QTDebug.txt"
Set f = OpenFile(sFilename, ForWriting, True)
No comments:
Post a Comment