kdjonesmtb2
Technical User
The vbscript code below pulls the last line of an existing txt file and adds it to new file - I wanted the code to pull all the lines in the exisitng txt file starting from row 2
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set f99 = fs
penTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\Text files\qtptest1.x12", ForReading,True)
'Skip through the first two lines
f99.readline
f99.readline
'Read till the end of file, if the line is not "end", split it based on ","
while not f99.AtEndOfStream
line = f99.readline()
if line <> "end" then
arr=split(line, "~")
q1.close
' Set fso=createobject("Scripting.FileSystemObject")
Set qfile1 = fso.CreateTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\Text files\qtptest_full.x12", ForAppending,True)
for each x99 in arr
qfile1.write(x99 & vbcrlf )
next
end if
wend
f99.close
'qfile1.Close
objworkbook.close 'Closes the Excel workbook each time a test case is incremented in the Global DataTable
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set f99 = fs
'Skip through the first two lines
f99.readline
f99.readline
'Read till the end of file, if the line is not "end", split it based on ","
while not f99.AtEndOfStream
line = f99.readline()
if line <> "end" then
arr=split(line, "~")
q1.close
' Set fso=createobject("Scripting.FileSystemObject")
Set qfile1 = fso.CreateTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\Text files\qtptest_full.x12", ForAppending,True)
for each x99 in arr
qfile1.write(x99 & vbcrlf )
next
end if
wend
f99.close
'qfile1.Close
objworkbook.close 'Closes the Excel workbook each time a test case is incremented in the Global DataTable