Sunday, December 12, 2010

VBScript Code | Reading all lines from File

Write the below written QTP code inside a notepad and save it as a .vbs file. You can either run it from command prompt or run it by double-clicking on it.
VBScript Code - The following code reads first line from a text file.

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set FSO = CreateObject("Scripting.FilesystemObject")
Set QTPfile = FSO.OpenTextFile("c:\myfile.txt", ForReading , False)

While not QTPfile.AtEndOfStream
a=QTPfile.ReadLine
Print a
Wend

0 comments: