Hello all,
I'm fairly new to VBscript so bare with me, I'm trying to create a script to get a line of test from one text document and then create a variable with it and then store that in one file. Once that Source text file entry has been updated then get it again and compare the two variables.
Heres what I have so far:
Code:
Set obj = CreateObject("Scripting.FileSystemObject")
Set objTextFile = obj.OpenTextFile("listdrives.txt",1)
For i = 1 to 84
objTextFile.ReadLine
Next
strLine = objTextFile.ReadLine
objTextFile.Close
If (obj.FileExists("disk1.txt")) Then
Set objWriteFile = obj.OpenTextFile("disk2.txt",2,true)
objWriteFile.WriteLine strLine
objWriteFile.WriteLine Date
objWriteFile.Close
Else
Set objWriteFile = obj.OpenTextFile("disk1.txt",2,true)
objWriteFile.WriteLine strLine
objWriteFile.WriteLine Date
objWriteFile.Close
End If
If (obj.FileExists("disk2.txt")) Then
Set objTextFile = obj.OpenTextFile("disk1.txt",1)
strLine1 = objTextFile.ReadAll
objTextFile.Close
Set objTextFile = obj.OpenTextFile("disk2.txt",1)
strLine2 = objTextFile.ReadAll
objTextFile.Close
If strLine1 = strLine2 Then
Set objWriteFile = obj.OpenTextFile("NotChanged.txt",2,true)
objWriteFile.WriteLine strLine1
objWriteFile.WriteLine strLine2
objWriteFile.Close
Else
Set objWriteFile = obj.OpenTextFile("Changed.txt",2,true)
objWriteFile.WriteLine strLine1
objWriteFile.WriteLine strLine2
objWriteFile.Close
Set objWriteFile = obj.OpenTextFile("disk1.txt",2,true)
objWriteFile.WriteLine strLine2
objWriteFile.Close
End If
End If
The result I get is first run -
Creates disk1.txt with correct content
Second run - Creates disk2.txt with correct content then compares the two and creates NotChanged.txt with correct content
Third run (When I change the 85th line in listdrives.txt) - Creates Changed.txt with correct content and modify's disk1.txt correctly
Fourth run (With 85th line in listdrives.txt unchanged) -
Modify's Changed.txt with correct content and modify's disk1.txt with correct content?
So even though both variables are the same its going to the Else clause for some reason?
Thanks in advance
Juz