$sRet = _CompareFiles_Proc(@ScriptDir & "\test.txt", @ScriptDir & "\test2.txt")
If $sRet = "" Then
MsgBox(64, "Compare Results", "There is no differences between the two files!")
Else
$sRet = StringReplace($sRet, "%ff", "test.txt")
$sRet = StringReplace($sRet, "%sf", "test2.txt")
MsgBox(64, "Compare Results", _
StringFormat("Differences in the files:\n\n%s", $sRet))
EndIf
Func _CompareFiles_Proc($sCompare_FirstFile, $sCompare_SecondFile)
If Not FileExists($sCompare_FirstFile) Or Not FileExists($sCompare_SecondFile) Then Return SetError(1, 0, 0)
Local $sRead_FirstFile = FileRead($sCompare_FirstFile)
Local $sRead_SecondFile = FileRead($sCompare_SecondFile)
If $sRead_FirstFile == $sRead_SecondFile Then Return ""
Local $aFirstFile_Array = StringSplit(StringStripCR($sRead_FirstFile), @LF)
Local $aSecondFile_Array = StringSplit(StringStripCR($sRead_SecondFile), @LF)
Local $iFirstFile_Ubound = UBound($aFirstFile_Array)-1
Local $iSecondFile_Ubound = UBound($aSecondFile_Array)-1
Local $iBiggest_Ubound = $iFirstFile_Ubound
If $iSecondFile_Ubound > $iFirstFile_Ubound Then $iBiggest_Ubound = $iSecondFile_Ubound
Local $sRet = ""
For $i = 1 To $iBiggest_Ubound
If $i > $iFirstFile_Ubound Then
$sRet &= $i & " => Missing line in the first file <%ff>" & @LF
ElseIf $i > $iSecondFile_Ubound Then
$sRet &= $i & " => Missing line in the second file <%sf>" & @LF
ElseIf StringCompare($aFirstFile_Array[$i], $aSecondFile_Array[$i], 1) <> 0 Then
$sRet &= $i & " => Lines are different in bouth files" & @LF
EndIf
Next
Return StringStripWS($sRet, 3)
EndFunc