Code : Tout sélectionner
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <Array.au3>
; exemple avec le fichier WindowsConstants.au3 (819 lignes)
; lecture du fichier
$file = FileRead(StringRegExpReplace(@Autoitexe, '(.+)\\[^\\]+', "$1") & "\Include\WindowsConstants.au3")
; création des 2 arrays (si utilisation de _FileReadToArray, mettre $Flag = 0 )
$aLines = StringRegExp($file, '(?m)(^.*)\R?', 3)
$aLines2 = $aLines
; rajout de quelques lignes supplémentaires dans les arrays
For $i = 15 to UBound($aLines)-1 step 100
_ArrayInsert($aLines, $i, "Global Const $WS_FAKE = extra line*" & Ceiling($i/100))
_ArrayInsert($aLines2, $i+3, "Global Const $WS_EX_FAKE = extra line 2*" & Ceiling($i/100))
_ArrayInsert($aLines2, $i+6, "Global Const $WM_FAKE = extra line 2*" & Ceiling($i/100) & "bis")
Next
; _ArrayDisplay($aLines)
$res = _ArrayCompareAndGetZeData($aLines, $aLines2, 0)
_ArrayDisplay($res)
;==============================================================
; $flag = 1 : retourne les items de l'array 1 absents dans la 2 (avec le n° de ligne)
; $flag = 2 : retourne les items de l'array 2 absents dans la 1 (avec le n° de ligne)
; $flag = 0 : retourne les deux
;==============================================================
Func _ArrayCompareAndGetZeData($array1, $array2, $flag = 0)
If $flag < 0 OR $flag > 2 Then $flag = 0
Local $array, $aTemp, $iRows, $iColumns
_SQLite_Startup()
_SQLite_Open() ; ':memory:'
_SQLite_Exec (-1, "CREATE TABLE table1 (id, items1); CREATE TABLE table2 (id, items2);")
_SQLite_Exec(-1, "Begin;")
For $i = 0 to UBound($array1)-1
_SQLite_Exec(-1, "INSERT INTO table1 VALUES (" & $i & ", " & _SQLite_FastEscape($array1[$i]) & ");")
Next
For $i = 0 to UBound($array2)-1
_SQLite_Exec(-1, "INSERT INTO table2 VALUES (" & $i & ", " & _SQLite_FastEscape($array2[$i]) & ");")
Next
_SQLite_Exec(-1, "Commit;")
Switch $flag
Case 1
_SQLite_GetTable2d(-1, "SELECT * FROM table1 " & _
"WHERE items1 NOT IN (SELECT items2 FROM table2) ;", $array, $iRows, $iColumns)
Case 2
_SQLite_GetTable2d(-1, "SELECT * FROM table2 " & _
"WHERE items2 NOT IN (SELECT items1 FROM table1) ;", $array, $iRows, $iColumns)
Case 0
_SQLite_GetTable2d(-1, "SELECT * FROM table1 " & _
"WHERE items1 NOT IN (SELECT items2 FROM table2) ;", $array, $iRows, $iColumns)
_SQLite_GetTable2d(-1, "SELECT * FROM table2 " & _
"WHERE items2 NOT IN (SELECT items1 FROM table1) ;", $aTemp, $iRows, $iColumns)
Local $n = UBound($array)-1, $m = UBound($aTemp)-1
Local $s = ($n > $m) ? $n : $m
Redim $array[$s+1][4]
For $i = 0 to $m
$array[$i][2] = $aTemp[$i][0]
$array[$i][3] = $aTemp[$i][1]
Next
$array[0][0] = $n
$array[0][1] = ""
$array[0][2] = $m
$array[0][3] = ""
EndSwitch
_SQLite_Close()
_SQLite_Shutdown()
Return $array
EndFunc