09-07-2008, 10:38 AM
If I understood your question correctly, you want to compare two files CurrentDIR.txt and LOG.txt and store their differences in a file name Files2Download.txt
Here is how you can convert it into a function.
you can call this function by :
Comp C:\CurrentDIR.txt, C:\LOG.txt, C:\Files2Download.txt
Here is how you can convert it into a function.
Code:
Function Comp (text_file1, text_file2, diff_file)
Const ForReading = 1, ForWriting = 2
Dim fso, txtFile, txtFile2, strLine1, strLine2, strMatch
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtFile1 = fso.OpenTextFile("text_file1", ForReading)
Set f = fso.OpenTextFile("diff_file", ForWriting, True)
Do Until txtFile1.AtEndOfStream
strMatch = False
strLine1 = txtFile1.Readline
Set txtFile2 = fso.OpenTextFile("text_file2", ForReading)
Do Until txtFile2.AtEndOfStream
strLine2 = txtFile2.Readline
If Trim(UCase(strLine2)) = Trim(UCase(strLine1)) Then
strMatch = True
Else
End If
Loop
txtFile2.Close
If strMatch <> True then
f.writeline strLine1
End If
Loop
f.Close
Wscript.Echo "Done"
End Function
you can call this function by :
Comp C:\CurrentDIR.txt, C:\LOG.txt, C:\Files2Download.txt
Want to fast track your QTP/UFT Learning? Join our UFT Training Course