1 | #include <GUIConstantsEx.au3> |
---|
2 | #include <Array.au3> |
---|
3 | |
---|
4 | Opt("GUIOnEventMode", 1) |
---|
5 | |
---|
6 | Func closeApp() |
---|
7 | Exit |
---|
8 | EndFunc |
---|
9 | |
---|
10 | Func linestoarray($file) |
---|
11 | Local $array[1] |
---|
12 | Local $file1HND = FileOpen($file, 0) |
---|
13 | If $file1HND = -1 Then |
---|
14 | MsgBox(16, "File Error", "Unable to open file") |
---|
15 | Return False |
---|
16 | EndIf |
---|
17 | Local $line |
---|
18 | Local $i = 0 |
---|
19 | While 1 |
---|
20 | $line = FileReadLine($file1HND) |
---|
21 | If @error = -1 Then ExitLoop |
---|
22 | ReDim $array[$i+1] |
---|
23 | $array[$i] = $line |
---|
24 | $i += 1 |
---|
25 | Wend |
---|
26 | FileClose($file1HND) |
---|
27 | Return $array |
---|
28 | EndFunc |
---|
29 | |
---|
30 | Func load() |
---|
31 | Global $mGUI = GUICreate("Compare and Merge", 360, 100, -1, -1) |
---|
32 | Global $file1 = GUICtrlCreateInput("", 10, 15 + 5, 250, 20) |
---|
33 | Local $b1 = GUICtrlCreateButton("Load", 270, 15 + 5, 40, 20) |
---|
34 | Global $file2 = GUICtrlCreateInput("", 10, 15 + 45, 250, 20) |
---|
35 | Local $b2 = GUICtrlCreateButton("Load", 270, 15 + 45, 40, 20) |
---|
36 | Local $bs = GUICtrlCreateButton("OK", 320, 15 + 5, 30, 60) |
---|
37 | |
---|
38 | GUISetOnEvent($GUI_EVENT_CLOSE, "closeApp") |
---|
39 | GUICtrlSetOnEvent($b1, "b1") |
---|
40 | GUICtrlSetOnEvent($b2, "b2") |
---|
41 | GUICtrlSetOnEvent($bs, "bs") |
---|
42 | |
---|
43 | GUISetState(@SW_SHOW) |
---|
44 | WinActivate($mGUI, "") |
---|
45 | EndFunc |
---|
46 | |
---|
47 | Func b1() |
---|
48 | Global $file1Loc = FileOpenDialog("Select file", @ScriptDir, "Text files (*.txt)", 3) |
---|
49 | GUICtrlSetData($file1, $file1Loc) |
---|
50 | EndFunc |
---|
51 | |
---|
52 | Func b2() |
---|
53 | Global $file2Loc = FileOpenDialog("Select file", @ScriptDir, "Text files (*.txt)", 3) |
---|
54 | GUICtrlSetData($file2, $file2Loc) |
---|
55 | EndFunc |
---|
56 | |
---|
57 | Func bs() |
---|
58 | Local $array[1] |
---|
59 | Local $array1 = linestoarray($file1Loc) |
---|
60 | Local $array2 = linestoarray($file2Loc) |
---|
61 | For $i=0 To UBound($array1)-1 Step 1 |
---|
62 | ReDim $array[$i+1] |
---|
63 | If $array1[$i] == $array2[$i] Then |
---|
64 | $array[$i] = $array1[$i] |
---|
65 | Else |
---|
66 | Local $ck = choice($array1[$i], $array2[$i]) |
---|
67 | If $ck == 1 Then $array[$i] = $array1[$i] |
---|
68 | If $ck == 2 Then $array[$i] = $array2[$i] |
---|
69 | EndIf |
---|
70 | Next |
---|
71 | _ArrayDisplay($array, "Results") |
---|
72 | EndFunc |
---|
73 | |
---|
74 | Func choice($ch1, $ch2) |
---|
75 | HotKeySet("{F8}", "sl") |
---|
76 | Global $checked = 0 |
---|
77 | Global $cGUI = GUICreate("Choice", 360, 100, -1, -1) |
---|
78 | GUISwitch($cGUI) |
---|
79 | Global $Checkbox1 = GUICtrlCreateCheckbox($ch1, 10, 15+5, 300, 20) |
---|
80 | Global $Checkbox2 = GUICtrlCreateCheckbox($ch2, 10, 15+45, 300, 20) |
---|
81 | Global $cbs = GUICtrlCreateButton("OK", 320, 15 + 5, 30, 60) |
---|
82 | GUISetOnEvent($GUI_EVENT_CLOSE, "closeApp") |
---|
83 | GUICtrlSetOnEvent($cbs, "sl") |
---|
84 | GUISetState(@SW_SHOW) |
---|
85 | WinActivate($cGUI, "") |
---|
86 | While Not $checked |
---|
87 | Sleep(50) |
---|
88 | WEnd |
---|
89 | GUISwitch($mGUI) |
---|
90 | GUIDelete($cGUI) |
---|
91 | Return $checked |
---|
92 | EndFunc |
---|
93 | |
---|
94 | Func sl() |
---|
95 | If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $checked = 1 |
---|
96 | If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $checked = 2 |
---|
97 | EndFunc |
---|
98 | |
---|
99 | load() |
---|
100 | |
---|
101 | While 1 |
---|
102 | Sleep(250) ; Just idle around |
---|
103 | WEnd |
---|