aqString.Compare compares the two strings, not the contents of the two files. The -1 means that the first string in your call has a combined ASCII value that is less than the value of string 2, which is correct because of the values of the path being different.
So, if you want to compare the contents of the files, there are three ways of doing this. The first way is to do a strict comparison of the files to determine if they are the same or different.
Sub CompareStrings
PathLogsCreate = "D:\Scripts\Logs\SQL\SQL2K\LogsCreate"
PathLogsFinais = "D:\Scripts\Logs\SQL\SQL2K\LogsFinais"
if not Files.Compare(pathLogsCreate&"\1-1.txt", pathLogsFinais&"\1-1.txt")
Then
Log.Error("The files do not match")
Else
Log.Message("The files match")
End If
End Sub
The second, is to read out the contents of each file into variables and then compare those contents whole-sale.
Sub CompareStrings
PathLogsCreate = "D:\Scripts\Logs\SQL\SQL2K\LogsCreate"
PathLogsFinais = "D:\Scripts\Logs\SQL\SQL2K\LogsFinais"
File1Contents = aqFile.ReadWholeTextFile(pathLogsCreate&"\1-1.txt", ctANSI)
File2Contents = aqFile.ReadWholTextFile(pathLogsFinais&"\1-1.txt", ctANSI)
CompareResult = aqString.Compare(File1Contents, File2Contents, 0)
if (CompareResult <> 0)
Then
Log.Error("The files do not match")
Else
Log.Message("The files match")
End If
End Sub
The third is more complex but will give your a cleaner look as to what the specific differences are on a line by line basis.
Sub CompareFiles
PathLogsCreate = "D:\Scripts\Logs\SQL\SQL2K\LogsCreate"
PathLogsFinais = "D:\Scripts\Logs\SQL\SQL2K\LogsFinais"
LineCount = 0
Set File1 = aqFile.OpenTextFile(PathLogsCreate&"\1-1.txt")
Set File2 = aqFile.OpenTextFile(PathLogsFinais&"\1-1.txt")
While not File1.IsEndOfFile()
File1Line = File1.Readln()
File2Line = File2.Readln()
LineCount = LineCount + 1
CompareResult = aqString.Compare(File1Line, File2Line, 0)
if (CompareResult <> 0) then
Log.Error("Line number " + VartoStr(LineCount) + " is different")
WEnd
End Sub
I've actually combined, in my experience, method 1 and method 3 to use method 1 to determine if the files are different and, if so, then use method 2 to find out which lines are different.
I'm sure we could even get into doing a character by character comparison to find out exactly which values are different in each line but that could just get rather silly and complex if all you need to know is whether or not they are the same.