youtuber Posted January 2, 2018 Share Posted January 2, 2018 (edited) Hello friends I want to delete the same ones in two text files completely and I want to combine everything in txt more expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 811, 474, 461, 223) $ButtonFile1 = GUICtrlCreateButton("File1", 24, 16, 75, 25) $EditFile1 = GUICtrlCreateEdit("" & @CRLF, 24, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Deleted = GUICtrlCreateEdit("" & @CRLF, 183, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Leftovers = GUICtrlCreateEdit("" & @CRLF, 341, 74, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $ButtonFile2 = GUICtrlCreateButton("File 2", 24, 256, 75, 25) $EditFile2 = GUICtrlCreateEdit("" & @CRLF, 26, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Deleted = GUICtrlCreateEdit("" & @CRLF, 181, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Leftovers = GUICtrlCreateEdit("" & @CRLF, 342, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1File2Deleted = GUICtrlCreateEdit("" & @CRLF, 504, 72, 273, 353, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("File 1", 24, 48, 29, 17) $Label2 = GUICtrlCreateLabel("Deleted File 1", 184, 48, 68, 17) $Label3 = GUICtrlCreateLabel("Leftovers File 1", 344, 48, 78, 17) $Label5 = GUICtrlCreateLabel("File 2", 27, 290, 29, 17) $Label6 = GUICtrlCreateLabel("Deleted File 2", 187, 290, 68, 17) $Label7 = GUICtrlCreateLabel("Leftovers File 2", 347, 290, 78, 17) $Label4 = GUICtrlCreateLabel("Combined all", 592, 48, 64, 17) $ButtonDelete = GUICtrlCreateButton("Delete same ones", 353, 216, 107, 49) $ButtonC = GUICtrlCreateButton("C", 736, 440, 43, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonFile1 $AddTxtFile1 = FileOpen(@ScriptDir & '\File1.txt', 0) GUICtrlSetData($EditFile1, FileRead($AddTxtFile1)) Case $ButtonFile2 $AddTxtFile2 = FileOpen(@ScriptDir & '\File2.txt', 0) GUICtrlSetData($EditFile2, FileRead($AddTxtFile2)) Case $ButtonDelete _deletesimilarFile1() _deletesimilarFile2() Case $ButtonC ClipPut(GUICtrlRead($EditFile1File2Deleted)) ToolTip('Copied') sleep(800) ToolTip("") EndSwitch WEnd Func _deletesimilarFile1() $aEditReadFile1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1)), @LF,2) $aUniques=_ArrayUnique($aEditReadFile1, 0, 0, 1) $aUniques2=_ArrayUnique($aEditReadFile1) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditReadFile1, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile1Deleted, $aUniques[$i] & @CRLF, 1) Next Dim $aSimilar[UBound($aEditReadFile1)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditReadFile1, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditReadFile1[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1) _ArraySort($aUniques3) For $i = 1 to UBound($aUniques3) - 1 GUICtrlSetData($EditFile1Leftovers, $aUniques3[$i] & @CRLF, 1) Next EndFunc Func _deletesimilarFile2() $aEditReadFile2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2)), @LF,2) $aUniques=_ArrayUnique($aEditReadFile2, 0, 0, 1) $aUniques2=_ArrayUnique($aEditReadFile2) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditReadFile2, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile2Deleted, $aUniques[$i] & @CRLF, 1) Next Dim $aSimilar[UBound($aEditReadFile2)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditReadFile2, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditReadFile2[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1) _ArraySort($aUniques3) For $i = 1 to UBound($aUniques3) - 1 GUICtrlSetData($EditFile2Leftovers, $aUniques3[$i] & @CRLF, 1) Next EndFunc  Edited January 3, 2018 by youtuber Link to comment Share on other sites More sharing options...
water Posted January 2, 2018 Share Posted January 2, 2018 And the question is? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki  Link to comment Share on other sites More sharing options...
youtuber Posted January 2, 2018 Author Share Posted January 2, 2018 I mean Spoiler  Link to comment Share on other sites More sharing options...
water Posted January 2, 2018 Share Posted January 2, 2018 You are posting in the "AutoIt General Help and Support" forum, but I still do not see a question Earthshine 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki  Link to comment Share on other sites More sharing options...
youtuber Posted January 3, 2018 Author Share Posted January 3, 2018 I want to compare two txt documents I want to delete the same words completely from both txt documents Link to comment Share on other sites More sharing options...
water Posted January 3, 2018 Share Posted January 3, 2018 Do you want us to write the code for you? Does your code return errors? Could you please add a question to your posts? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki  Link to comment Share on other sites More sharing options...
Earthshine Posted January 3, 2018 Share Posted January 3, 2018 I want an Ford Focus RS but that won't get me one. My resources are limited. You must ask the right questions  Link to comment Share on other sites More sharing options...
youtuber Posted January 3, 2018 Author Share Posted January 3, 2018 For example I have two txt files content file1.txt test test 123 abcd content file2.txt test test 123 abc expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 811, 474, 461, 223) $ButtonFile1 = GUICtrlCreateButton("File1", 24, 16, 75, 25) $EditFile1 = GUICtrlCreateEdit("" & @CRLF, 24, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Deleted = GUICtrlCreateEdit("" & @CRLF, 183, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Leftovers = GUICtrlCreateEdit("" & @CRLF, 341, 74, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $ButtonFile2 = GUICtrlCreateButton("File 2", 24, 256, 75, 25) $EditFile2 = GUICtrlCreateEdit("" & @CRLF, 26, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Deleted = GUICtrlCreateEdit("" & @CRLF, 181, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Leftovers = GUICtrlCreateEdit("" & @CRLF, 342, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1File2Deleted = GUICtrlCreateEdit("" & @CRLF, 504, 72, 273, 353, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("File 1", 24, 48, 29, 17) $Label2 = GUICtrlCreateLabel("Deleted File 1", 184, 48, 68, 17) $Label3 = GUICtrlCreateLabel("Leftovers File 1", 344, 48, 78, 17) $Label5 = GUICtrlCreateLabel("File 2", 27, 290, 29, 17) $Label6 = GUICtrlCreateLabel("Deleted File 2", 187, 290, 68, 17) $Label7 = GUICtrlCreateLabel("Leftovers File 2", 347, 290, 78, 17) $Label4 = GUICtrlCreateLabel("Combined all", 592, 48, 64, 17) $ButtonDelete = GUICtrlCreateButton("Delete same ones", 353, 216, 107, 49) $ButtonC = GUICtrlCreateButton("C", 736, 440, 43, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonFile1 $AddTxtFile1 = FileOpen(@ScriptDir & '\File1.txt', 0) GUICtrlSetData($EditFile1, FileRead($AddTxtFile1)) Case $ButtonFile2 $AddTxtFile2 = FileOpen(@ScriptDir & '\File2.txt', 0) GUICtrlSetData($EditFile2, FileRead($AddTxtFile2)) Case $ButtonDelete _deletesimilarFile1() _deletesimilarFile2() Case $ButtonC ClipPut(GUICtrlRead($EditFile1File2Deleted)) ToolTip('Copied') sleep(800) ToolTip("") EndSwitch WEnd Func _deletesimilarFile1() $aEditReadFile1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1)), @LF,2) $aUniques=_ArrayUnique($aEditReadFile1, 0, 0, 1) $aUniques2=_ArrayUnique($aEditReadFile1) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditReadFile1, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile1Deleted, $aUniques[$i] & @CRLF, 1) Next Dim $aSimilar[UBound($aEditReadFile1)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditReadFile1, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditReadFile1[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1) _ArraySort($aUniques3) For $i = 1 to UBound($aUniques3) - 1 GUICtrlSetData($EditFile1Leftovers, $aUniques3[$i] & @CRLF, 1) Next EndFunc Func _deletesimilarFile2() $aEditReadFile2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2)), @LF,2) $aUniques=_ArrayUnique($aEditReadFile2, 0, 0, 1) $aUniques2=_ArrayUnique($aEditReadFile2) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditReadFile2, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile2Deleted, $aUniques[$i] & @CRLF, 1) Next Dim $aSimilar[UBound($aEditReadFile2)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditReadFile2, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditReadFile2[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1) _ArraySort($aUniques3) For $i = 1 to UBound($aUniques3) - 1 GUICtrlSetData($EditFile2Leftovers, $aUniques3[$i] & @CRLF, 1) Next EndFunc I delete the same ones and then I want to do the following Func _deletesimilarAll() $EditFile2LeftoversReadFile1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1Leftovers)), @LF,2) $EditFile2LeftoversReadFile2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2Leftovers)), @LF,2) $aUniques =_ArrayUnique($EditFile2LeftoversReadFile1) $aUniques2 =_ArrayUnique($EditFile2LeftoversReadFile2) For $i = 1 To UBound($aUniques) - 1 $DeleteAllSmilar = _ArrayDelete($aUniques And $aUniques2) GUICtrlSetData($EditFile1File2Deleted abc abcd Next EndFunc  Link to comment Share on other sites More sharing options...
iamtheky Posted January 3, 2018 Share Posted January 3, 2018 I dont quite understand the question, does this help? #include<array.au3> $arr1 = stringsplit("test" & @CR & "test" & @CR & "123" & @CR & "abcd" , @CR , 2) ; strinsplit the fileread or _FRTA $arr2 = stringsplit("test" & @CR & "test" & @CR & "123" & @CR & "abc" , @CR , 2) local $aOut[0] $arr1 = _ArrayUnique($arr1 , 0 , 0 , 0 , 0) ; unique each arr $arr2 = _ArrayUnique($arr2 , 0 , 0 , 0 , 0) For $i = ubound($arr1) - 1 To 0 step - 1 If $arr1[$i] = $arr2[$i] Then ; do the things _ArrayAdd($aOut , $arr1[$i]) _ArrayDelete($arr1 , $i) _ArrayDelete($arr2 , $i) EndIf Next _ArrayDisplay($aOut , "Matches") ; all the options for output _ArrayDisplay($arr1 , "Only in arr1") _ArrayDisplay($arr2 , "Only in arr2") _ArrayConcatenate($arr1 , $arr2) ; and concatenate to get all nons _ArrayDisplay($arr1 , "nonmatches") Â youtuber 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
youtuber Posted January 3, 2018 Author Share Posted January 3, 2018 @iamtheky Thank you Yes, that's what I want But how do I adapt it to my codes? #include<array.au3> $arr1 = stringsplit("test" & @CR & "test" & @CR & "123" & @CR & "abcd" , @CR , 2) ; strinsplit the fileread or _FRTA $arr2 = stringsplit("test" & @CR & "test" & @CR & "123" & @CR & "abc" , @CR , 2) local $aOut[0] $arr1 = _ArrayUnique($arr1 , 0 , 0 , 0 , 0) ; unique each arr $arr2 = _ArrayUnique($arr2 , 0 , 0 , 0 , 0) For $i = ubound($arr1) - 1 To 0 step - 1 If $arr1[$i] = $arr2[$i] Then ; do the things _ArrayAdd($aOut , $arr1[$i]) _ArrayDelete($arr1 , $i) _ArrayDelete($arr2 , $i) EndIf Next _ArrayConcatenate($arr1 , $arr2) ; and concatenate to get all nons _ArrayDisplay($arr1 , "nonmatches")  Link to comment Share on other sites More sharing options...
iamtheky Posted January 3, 2018 Share Posted January 3, 2018 I'm more of an array manipulator.... There are better GUI people than me who will probably beat me to it, but im trying. youtuber 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
youtuber Posted January 3, 2018 Author Share Posted January 3, 2018 (edited) I do, but I think there seems to be a problem There is a problem with detecting numeric values Spoiler expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 811, 474, 461, 223) $ButtonFile1 = GUICtrlCreateButton("File1", 24, 16, 75, 25) $EditFile1 = GUICtrlCreateEdit("" & @CRLF, 24, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Deleted = GUICtrlCreateEdit("" & @CRLF, 183, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Leftovers = GUICtrlCreateEdit("" & @CRLF, 341, 74, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $ButtonFile2 = GUICtrlCreateButton("File 2", 24, 256, 75, 25) $EditFile2 = GUICtrlCreateEdit("" & @CRLF, 26, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Deleted = GUICtrlCreateEdit("" & @CRLF, 181, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Leftovers = GUICtrlCreateEdit("" & @CRLF, 342, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1File2Deleted = GUICtrlCreateEdit("" & @CRLF, 504, 72, 273, 353, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("File 1", 24, 48, 29, 17) $Label2 = GUICtrlCreateLabel("Deleted File 1", 184, 48, 68, 17) $Label3 = GUICtrlCreateLabel("Leftovers File 1", 344, 48, 78, 17) $Label5 = GUICtrlCreateLabel("File 2", 27, 290, 29, 17) $Label6 = GUICtrlCreateLabel("Deleted File 2", 187, 290, 68, 17) $Label7 = GUICtrlCreateLabel("Leftovers File 2", 347, 290, 78, 17) $Label4 = GUICtrlCreateLabel("Combined all", 592, 48, 64, 17) $ButtonDelete = GUICtrlCreateButton("Delete same ones", 353, 216, 107, 49) $ButtonC = GUICtrlCreateButton("C", 736, 440, 43, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonFile1 $AddTxtFile1 = FileOpen(@ScriptDir & '\File1.txt', 0) GUICtrlSetData($EditFile1, FileRead($AddTxtFile1)) Case $ButtonFile2 $AddTxtFile2 = FileOpen(@ScriptDir & '\File2.txt', 0) GUICtrlSetData($EditFile2, FileRead($AddTxtFile2)) Case $ButtonDelete _deletesimilarFile1() _deletesimilarFile2() _deletesimilarAll() Case $ButtonC ClipPut(GUICtrlRead($EditFile1File2Deleted)) ToolTip('Copied') sleep(800) ToolTip("") EndSwitch WEnd Func _deletesimilarFile1() $aEditReadFile1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1)), @LF,2) $aUniques=_ArrayUnique($aEditReadFile1, 0, 0, 1) $aUniques2=_ArrayUnique($aEditReadFile1) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditReadFile1, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile1Deleted, $aUniques[$i] & @CRLF, 1) Next Dim $aSimilar[UBound($aEditReadFile1)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditReadFile1, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditReadFile1[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1) _ArraySort($aUniques3) For $i = 1 to UBound($aUniques3) - 1 GUICtrlSetData($EditFile1Leftovers, $aUniques3[$i] & @CRLF, 1) Next EndFunc Func _deletesimilarFile2() $aEditReadFile2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2)), @LF,2) $aUniques=_ArrayUnique($aEditReadFile2, 0, 0, 1) $aUniques2=_ArrayUnique($aEditReadFile2) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditReadFile2, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile2Deleted, $aUniques[$i] & @CRLF, 1) Next Dim $aSimilar[UBound($aEditReadFile2)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditReadFile2, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditReadFile2[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1) _ArraySort($aUniques3) For $i = 1 to UBound($aUniques3) - 1 GUICtrlSetData($EditFile2Leftovers, $aUniques3[$i] & @CRLF, 1) Next EndFunc Func _deletesimilarAll() $arr1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1Leftovers)), @LF,2) $arr2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2Leftovers)), @LF,2) local $aOut[0] $arr1 = _ArrayUnique($arr1 , 0 , 0 , 0 , 0) ; unique each arr $arr2 = _ArrayUnique($arr2 , 0 , 0 , 0 , 0) For $i = ubound($arr1) - 1 To 0 step - 1 If $arr1[$i] = $arr2[$i] Then ; do the things _ArrayAdd($aOut , $arr1[$i]) _ArrayDelete($arr1 , $i) _ArrayDelete($arr2 , $i) EndIf _ArrayConcatenate($arr1 , $arr2) ; and concatenate to get all nons GUICtrlSetData($EditFile1File2Deleted, $arr1[$i] & @CRLF, 1) Next EndFunc  Edited January 3, 2018 by youtuber Link to comment Share on other sites More sharing options...
youtuber Posted January 4, 2018 Author Share Posted January 4, 2018 Exactly as I want but how to adjust according to my codes #include<array.au3> $arr1 = stringsplit("test" & @CR & "test" & @CR & "123" & @CR & "abcd" , @CR , 2) ; strinsplit the fileread or _FRTA $arr2 = stringsplit("test" & @CR & "test" & @CR & "123" & @CR & "abc" , @CR , 2) local $aOut[0] $arr1 = _ArrayUnique($arr1 , 0 , 0 , 0 , 0) ; unique each arr $arr2 = _ArrayUnique($arr2 , 0 , 0 , 0 , 0) For $i = ubound($arr1) - 1 To 0 step - 1 If $arr1[$i] = $arr2[$i] Then ; do the things _ArrayAdd($aOut , $arr1[$i]) _ArrayDelete($arr1 , $i) _ArrayDelete($arr2 , $i) EndIf Next _ArrayConcatenate($arr1 , $arr2) ; and concatenate to get all nons _ArrayDisplay($arr1 , "nonmatches") Func _deletesimilarAll() $arr1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1Leftovers)), @LF,2) $arr2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2Leftovers)), @LF,2) local $aOut[0] $arr1 = _ArrayUnique($arr1 , 0 , 0 , 0 , 0) ; unique each arr $arr2 = _ArrayUnique($arr2 , 0 , 0 , 0 , 0) For $i = ubound($arr1) - 1 To 0 step -1 If $arr1[$i] = $arr2[$i] Then ; do the things _ArrayAdd($aOut , $arr1[$i]) _ArrayDelete($arr1 , $i) _ArrayDelete($arr2 , $i) EndIf _ArrayConcatenate($arr1 , $arr2) ; and concatenate to get all nons GUICtrlSetData($EditFile1File2Deleted, $arr1[$i] & @CRLF, 1) Next EndFunc all of the codes expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 811, 474, 461, 223) $ButtonFile1 = GUICtrlCreateButton("File1", 24, 16, 75, 25) $EditFile1 = GUICtrlCreateEdit("" & @CRLF, 24, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Deleted = GUICtrlCreateEdit("" & @CRLF, 183, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Leftovers = GUICtrlCreateEdit("" & @CRLF, 341, 74, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $ButtonFile2 = GUICtrlCreateButton("File 2", 24, 256, 75, 25) $EditFile2 = GUICtrlCreateEdit("" & @CRLF, 26, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Deleted = GUICtrlCreateEdit("" & @CRLF, 181, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Leftovers = GUICtrlCreateEdit("" & @CRLF, 342, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1File2Deleted = GUICtrlCreateEdit("" & @CRLF, 504, 72, 273, 353, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("File 1", 24, 48, 29, 17) $Label2 = GUICtrlCreateLabel("Deleted File 1", 184, 48, 68, 17) $Label3 = GUICtrlCreateLabel("Leftovers File 1", 344, 48, 78, 17) $Label5 = GUICtrlCreateLabel("File 2", 27, 290, 29, 17) $Label6 = GUICtrlCreateLabel("Deleted File 2", 187, 290, 68, 17) $Label7 = GUICtrlCreateLabel("Leftovers File 2", 347, 290, 78, 17) $Label4 = GUICtrlCreateLabel("Combined all", 592, 48, 64, 17) $ButtonDelete = GUICtrlCreateButton("Delete same ones", 353, 216, 107, 49) $ButtonC = GUICtrlCreateButton("C", 736, 440, 43, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonFile1 $AddTxtFile1 = FileOpen(@ScriptDir & '\File1.txt', 0) GUICtrlSetData($EditFile1, FileRead($AddTxtFile1)) Case $ButtonFile2 $AddTxtFile2 = FileOpen(@ScriptDir & '\File2.txt', 0) GUICtrlSetData($EditFile2, FileRead($AddTxtFile2)) Case $ButtonDelete _deletesimilarFile1() _deletesimilarFile2() _deletesimilarAll() Case $ButtonC ClipPut(GUICtrlRead($EditFile1File2Deleted)) ToolTip('Copied') sleep(800) ToolTip("") EndSwitch WEnd Func _deletesimilarFile1() $aEditReadFile1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1)), @LF,2) $aUniques=_ArrayUnique($aEditReadFile1, 0, 0, 0, 1) $aUniques2=_ArrayUnique($aEditReadFile1) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditReadFile1, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile1Deleted, $aUniques[$i] & @CRLF, 1) Next Dim $aSimilar[UBound($aEditReadFile1)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditReadFile1, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditReadFile1[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 0, 0) _ArraySort($aUniques3) For $i = 0 to UBound($aUniques3) - 1 GUICtrlSetData($EditFile1Leftovers, $aUniques3[$i] & @CRLF, 1) Next EndFunc Func _deletesimilarFile2() $aEditReadFile2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2)), @LF,2) $aUniques=_ArrayUnique($aEditReadFile2, 0, 0, 0, 1) $aUniques2=_ArrayUnique($aEditReadFile2) For $i = 1 To UBound($aUniques) - 1 $aPos = _ArrayFindAll($aEditReadFile2, $aUniques[$i], 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile2Deleted, $aUniques[$i] & @CRLF, 1) Next Dim $aSimilar[UBound($aEditReadFile2)] $c = 0 For $i = 1 To UBound($aUniques2) - 1 $aPos = _ArrayFindAll($aEditReadFile2, $aUniques2[$i]) If UBound($aPos) > 0 Then For $j = 0 To UBound($aPos) - 1 $aSimilar[$c] = $aEditReadFile2[$aPos[$j]] $c += 1 Next EndIf Next ReDim $aSimilar[$c] $aUniques3=_ArrayUnique($aSimilar, 0, 0, 0, 0) _ArraySort($aUniques3) For $i = 0 to UBound($aUniques3) - 1 GUICtrlSetData($EditFile2Leftovers, $aUniques3[$i] & @CRLF, 1) Next EndFunc Func _deletesimilarAll() $arr1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1Leftovers)), @LF,2) $arr2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2Leftovers)), @LF,2) local $aOut[0] $arr1 = _ArrayUnique($arr1 , 0 , 0 , 0 , 0) ; unique each arr $arr2 = _ArrayUnique($arr2 , 0 , 0 , 0 , 0) For $i = ubound($arr1) - 1 To 0 step -1 If $arr1[$i] = $arr2[$i] Then ; do the things _ArrayAdd($aOut , $arr1[$i]) _ArrayDelete($arr1 , $i) _ArrayDelete($arr2 , $i) EndIf _ArrayConcatenate($arr1 , $arr2) ; and concatenate to get all nons GUICtrlSetData($EditFile1File2Deleted, $arr1[$i] & @CRLF, 1) Next EndFunc  Link to comment Share on other sites More sharing options...
Earthshine Posted January 4, 2018 Share Posted January 4, 2018 (edited) you will probably have to develop an AutoIt function using FileRead to read in your bits for processing. Loop based I would imagine. in C# this is trivial but not so in this language Edited January 4, 2018 by Earthshine My resources are limited. You must ask the right questions  Link to comment Share on other sites More sharing options...
youtuber Posted January 4, 2018 Author Share Posted January 4, 2018 (edited) content file1.txt test test 123 abcd content file2.txt test test 123 abc In those two files, those who are unlike each other "abcd and abc" I want to add EditFile1File2Deleted to Editbox   GUICtrlSetData($EditFile1File2Deleted Func _deletesimilarAll() $arr1 = StringSplit(StringStripCR(GUICtrlRead($EditFile1Leftovers)), @LF,2) $arr2 = StringSplit(StringStripCR(GUICtrlRead($EditFile2Leftovers)), @LF,2) $aUniques1 = _ArrayUnique($arr1) $aUniques2 = _ArrayUnique($arr2) For $i = 1 To UBound($aUniques1) - 1 If $aUniques1[$i] = $aUniques2[$i] Then _ArrayDelete($aUniques1[$i],$aUniques2[$i]) GUICtrlSetData($EditFile1File2Deleted, $arr1[$i] & @CRLF & $arr2[$i] & @CRLF, 1) EndIf Next EndFunc  Edited January 4, 2018 by youtuber Link to comment Share on other sites More sharing options...
youtuber Posted January 4, 2018 Author Share Posted January 4, 2018 (edited) A sample excel vba code Sub CLEAR_SIMILAR_REGISTRATIONS() For i = 1 To [A65536].End(3).Row COUNT = WorksheetFunction.CountIf([A:A], Cells(i, 1)) If COUNT > 1 Then Columns(1).Replace What:=Cells(i, 1), Replacement:="" End If Next Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete MsgBox "Similar entries deleted.", vbInformation End Sub or DefInt A, C, I, S Sub Simlr() Dim array() For i = 2 To Range("A65536").End(3).Row If WorksheetFunction.CountIf(Range("A2:A" & i), Cells(i, "A")) > 1 Then ReDim Preserve array(a) array(a) = Cells(i, "A") a = a + 1 End If Next i On Error GoTo eror For c = Range("A65536").End(3).Row To 2 Step -1 For s = LBound(array) To UBound(array) If Cells(c, 1) = array(s) Then Rows(c).Delete End If Next s Next c eror: MsgBox "No similar data found.", vbInformation, "information" End Sub Please help in this regard  Edited January 4, 2018 by youtuber Link to comment Share on other sites More sharing options...
kylomas Posted January 6, 2018 Share Posted January 6, 2018 youtuber, This is an SQL implementation of what I understand of your needs... expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <array.au3> #include <SQLite.au3> #include <EditConstants.au3> #AutoIt3Wrapper_Add_Constants=n Local $gui010 = GUICreate('File Comapare Example', 1300, 620) GUICtrlCreateLabel('File 1 raw', 10, 15, 100, 15) Local $f1raw = GUICtrlCreateEdit('', 10, 30, 200, 200, $ws_vscroll) GUICtrlCreateLabel('File 1 distinct', 220, 15, 100, 15) Local $f1distinct = GUICtrlCreateEdit('', 220, 30, 200, 200, $ws_vscroll) GUICtrlCreateLabel('File 1 dups', 430, 15, 100, 15) Local $f1dups = GUICtrlCreateEdit('', 430, 30, 200, 200, $ws_vscroll) GUICtrlCreateLabel('File 1 not in file 2', 640, 15, 100, 15) Local $f1notinf2 = GUICtrlCreateEdit('', 640, 30, 200, 200, $ws_vscroll) GUICtrlCreateLabel('File 1 in file 2', 850, 15, 100, 15) Local $f1inf2 = GUICtrlCreateEdit('', 850, 30, 200, 200, $ws_vscroll) GUICtrlCreateLabel('Enter File 1 Path or ''...'' for select dialog', 10, 250, 200, 20) Local $f1 = GUICtrlCreateInput('', 10, 270, 400, 20) Local $selectf1 = GUICtrlCreateLabel('...', 420, 270, 20, 20) GUICtrlSetFont(-1, 14, 800) GUICtrlSetCursor($selectf1, 0) GUICtrlCreateLabel('File 2 raw', 10, 315, 100, 15) Local $f2raw = GUICtrlCreateEdit('', 10, 330, 200, 200, $ws_vscroll) GUICtrlCreateLabel('File 2 distinct', 220, 315, 100, 15) Local $f2distinct = GUICtrlCreateEdit('', 220, 330, 200, 200, $ws_vscroll) GUICtrlCreateLabel('File 2 dups', 430, 315, 100, 15) Local $f2dups = GUICtrlCreateEdit('', 430, 330, 200, 200, $ws_vscroll) GUICtrlCreateLabel('File 2 not in file 1', 640, 315, 100, 15) Local $f2notinf1 = GUICtrlCreateEdit('', 640, 330, 200, 200, $ws_vscroll) GUICtrlCreateLabel('File 2 in file 1', 850, 315, 100, 15) Local $f2inf1 = GUICtrlCreateEdit('', 850, 330, 200, 200, $ws_vscroll) GUICtrlCreateLabel('Combined distinct entries', 1070, 15, 100, 15) Local $comb = GUICtrlCreateEdit('', 1070, 30, 200, 500, $ws_vscroll) GUICtrlCreateLabel('Enter File 2 Path or ''...'' for select dialog', 10, 550, 200, 20) Local $f2 = GUICtrlCreateInput('', 10, 570, 400, 20) Local $selectf2 = GUICtrlCreateLabel('...', 420, 570, 20, 20) ;, $ss_centerimage) GUICtrlSetFont(-1, 14, 800) GUICtrlSetCursor($selectf2, 0) Local $pop = GUICtrlCreateButton('Copulate', 1100, 570, 150, 20) GUISetState() Local $aRetFiles While 1 Switch GUIGetMsg() Case $gui_event_close Exit Case $selectf1 _getf1() Case $selectf2 _getf2() Case $pop $aRetFiles = Get_File_Differences(GUICtrlRead($f1), GUICtrlRead($f2)) If @error <> 0 Then Exit MsgBox(17, 'Error from Get_File_Differences', '@ERROR = ' & @error) _pop($aRetFiles) EndSwitch WEnd Func _getf1() Local $sFileOpenDialog = FileOpenDialog('Selct File', @ScriptDir & "\", "Text (*.txt)", $FD_FILEMUSTEXIST) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") Else GUICtrlSetData($f1, StringReplace($sFileOpenDialog, "|", @CRLF)) EndIf FileChangeDir(@ScriptDir) EndFunc ;==>_getf1 Func _getf2() Local $sFileOpenDialog = FileOpenDialog('Selct File', @ScriptDir & "\", "Text (*.txt)", $FD_FILEMUSTEXIST) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") Else GUICtrlSetData($f2, StringReplace($sFileOpenDialog, "|", @CRLF)) EndIf FileChangeDir(@ScriptDir) EndFunc ;==>_getf2 Func _pop($filearray) GUICtrlSetData($f1raw, FileRead(GUICtrlRead($f1))) GUICtrlSetData($f2raw, FileRead(GUICtrlRead($f2))) GUICtrlSetData($f1distinct, _ArrayToString($filearray[0])) GUICtrlSetData($f1dups, _ArrayToString($filearray[1])) GUICtrlSetData($f1notinf2, _ArrayToString($filearray[2])) GUICtrlSetData($f1inf2, _ArrayToString($filearray[3])) GUICtrlSetData($f2distinct, _ArrayToString($filearray[4])) GUICtrlSetData($f2dups, _ArrayToString($filearray[5])) GUICtrlSetData($f2notinf1, _ArrayToString($filearray[6])) GUICtrlSetData($f2inf1, _ArrayToString($filearray[7])) GUICtrlSetData($comb, _ArrayToString($filearray[8])) EndFunc ;==>_pop Func Get_File_Differences($file1, $file2) _SQLite_Startup() If @error Then Return SetError(1, @error) _SQLite_Open() If @error Then Return SetError(2, @error) Local $afile1 = StringSplit(FileRead($file1), @CRLF, 3) Local $afile2 = StringSplit(FileRead($file2), @CRLF, 3) Local $sql = 'drop table if exists File1; drop table if exists File2;' If _SQLite_Exec(-1, $sql) <> $sqlite_ok Then Return SetError(5) Local $sql = 'drop table if exists f1distinct; drop table if exists f2distinct;' If _SQLite_Exec(-1, $sql) <> $sqlite_ok Then Return SetError(6) Local $sql = 'create table File1 (col1); create table File2 (col1);' If _SQLite_Exec(-1, $sql) <> $sqlite_ok Then Return SetError(3) $sql = '' For $1 = 0 To UBound($afile1) - 1 If $afile1[$1] = '' Then ContinueLoop $sql &= 'insert into file1 values(' & _SQLite_FastEscape($afile1[$1]) & ');' Next For $1 = 0 To UBound($afile2) - 1 If $afile2[$1] = '' Then ContinueLoop $sql &= 'insert into file2 values(' & _SQLite_FastEscape($afile2[$1]) & ');' Next If _SQLite_Exec(-1, $sql) <> $sqlite_ok Then Return SetError(4) ; $aret elements ; [0] array of distinct entries file 1 ; [1] array of dups in file 1 ; [2] array of file 1 entries not in file 2 ; [3] array of file 1 entries in file 2 ; [4] array of distinct entries file 2 ; [5] array of dups in file 2 ; [6] array of file 2 entries not in file 1 ; [7] array of file 2 entries in file 1 ; [8] array of file 1 and file 2 distinct entries Local $aret[9] Local $ret, $arows, $icol, $irow _SQLite_Exec(-1, 'create table f1distinct as select distinct(col1) from file1;') _SQLite_GetTable2d(-1, 'select col1 from f1distinct order by col1 asc', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[0] = $arows _SQLite_GetTable2d(-1, 'SELECT col1 FROM file1 GROUP BY col1 HAVING ( COUNT(col1) > 1 ) order by col1 asc;', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[1] = $arows ;_arraydisplay($arows) _SQLite_GetTable2d(-1, 'select col1 from f1distinct where col1 not in (select col1 from file2) order by col1 asc;', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[2] = $arows _SQLite_GetTable2d(-1, 'select col1 from f1distinct where col1 in (select col1 from file2) order by col1 asc;', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[3] = $arows _SQLite_Exec(-1, 'create table f2distinct as select distinct(col1) from file2;') _SQLite_GetTable2d(-1, 'select col1 from f2distinct order by col1 asc;', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[4] = $arows _SQLite_GetTable2d(-1, 'SELECT col1 FROM file2 GROUP BY col1 HAVING ( COUNT(col1) > 1 ) order by col1 asc;', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[5] = $arows _SQLite_GetTable2d(-1, 'select col1 from f2distinct where col1 not in (select col1 from file1) order by col1 asc;', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[6] = $arows _SQLite_GetTable2d(-1, 'select col1 from f2distinct where col1 in (select col1 from file1) order by col1 asc;', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[7] = $arows _SQLite_GetTable2d(-1, 'select col1 from file1 union select col1 from file2 order by col1 asc;', $arows, $icol, $irow) _ArrayDelete($arows, 0) $aret[8] = $arows Return $aret EndFunc ;==>Get_File_Differences The files that I used for testing are file2.txt and file1.txt kylomas youtuber 1 Forum Rules        Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
youtuber Posted January 7, 2018 Author Share Posted January 7, 2018 @kylomas I get an error message Spoiler  Link to comment Share on other sites More sharing options...
water Posted January 7, 2018 Share Posted January 7, 2018 Did you try to chase down this error (it's quite easy)? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki  Link to comment Share on other sites More sharing options...
farouk12 Posted January 7, 2018 Share Posted January 7, 2018 Hmm, Test this. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 811, 474, 461, 223) $ButtonFile1 = GUICtrlCreateButton("File1", 24, 16, 75, 25) $EditFile1 = GUICtrlCreateEdit("" & @CRLF, 24, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Deleted = GUICtrlCreateEdit("" & @CRLF, 183, 72, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1Leftovers = GUICtrlCreateEdit("" & @CRLF, 341, 74, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $ButtonFile2 = GUICtrlCreateButton("File 2", 24, 256, 75, 25) $EditFile2 = GUICtrlCreateEdit("" & @CRLF, 26, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Deleted = GUICtrlCreateEdit("" & @CRLF, 181, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile2Leftovers = GUICtrlCreateEdit("" & @CRLF, 342, 311, 137, 113, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $EditFile1File2Deleted = GUICtrlCreateEdit("" & @CRLF, 504, 72, 273, 353, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL)) GUICtrlSetData(-1, "") $Label1 = GUICtrlCreateLabel("File 1", 24, 48, 29, 17) $Label2 = GUICtrlCreateLabel("Deleted File 1", 184, 48, 68, 17) $Label3 = GUICtrlCreateLabel("Leftovers File 1", 344, 48, 78, 17) $Label5 = GUICtrlCreateLabel("File 2", 27, 290, 29, 17) $Label6 = GUICtrlCreateLabel("Deleted File 2", 187, 290, 68, 17) $Label7 = GUICtrlCreateLabel("Leftovers File 2", 347, 290, 78, 17) $Label4 = GUICtrlCreateLabel("Combined all", 592, 48, 64, 17) $ButtonDelete = GUICtrlCreateButton("Delete same ones", 353, 216, 107, 49) $ButtonC = GUICtrlCreateButton("C", 736, 440, 43, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonFile1 $AddTxtFile1 = FileOpen(@ScriptDir & '\File1.txt', 0) GUICtrlSetData($EditFile1, FileRead($AddTxtFile1)) Case $ButtonFile2 $AddTxtFile2 = FileOpen(@ScriptDir & '\File2.txt', 0) GUICtrlSetData($EditFile2, FileRead($AddTxtFile2)) Case $ButtonDelete _deletesimilarFile1() _deletesimilarFile2() _deletesimilarAll() Case $ButtonC ClipPut(GUICtrlRead($EditFile1File2Deleted)) ToolTip('Copied') sleep(800) ToolTip("") EndSwitch WEnd Func _deletesimilarFile1() $aEditReadFile1 = StringRegExp(GUICtrlRead($EditFile1),".+",3) $aUniques=_ArrayUnique($aEditReadFile1,0,0,0,0) For $i In $aUniques $aPos = _ArrayFindAll($aEditReadFile1, $i, 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile1Deleted, $aUniques[$i] & @CRLF, 1) Next _ArraySort($aUniques) GUICtrlSetData($EditFile1Leftovers, _ArrayToString($aUniques,@CRLF), 1) EndFunc Func _deletesimilarFile2() $aEditReadFile2 = StringRegExp(GUICtrlRead($EditFile2),".+",3) $aUniques=_ArrayUnique($aEditReadFile2,0,0,0,0) For $i In $aUniques $aPos = _ArrayFindAll($aEditReadFile2, $i, 0, 0, 1) If UBound($aPos) > 1 Then GUICtrlSetData($EditFile2Deleted, $aUniques[$i] & @CRLF, 1) Next _ArraySort($aUniques) GUICtrlSetData($EditFile2Leftovers, _ArrayToString($aUniques,@CRLF), 1) EndFunc Func _deletesimilarAll() $arr = StringRegExp(GUICtrlRead($EditFile1Leftovers),".+",3) $arr2 = StringRegExp(GUICtrlRead($EditFile2Leftovers),".+",3) _ArrayConcatenate($arr , $arr2) ; and concatenate to get all nons $i=0 Do $aPos = _ArrayFindAll($arr, $arr[$i], 0, 0, 1) If UBound($aPos) > 1 Then $K=0 For $n In $aPos _ArrayDelete($arr , $n-$K) $K+=1 Next EndIf $i+=1 Until $i>ubound($arr) - 1 _ArraySort($arr) GUICtrlSetData($EditFile1File2Deleted, _ArrayToString($arr,@CRLF), 1) EndFunc  Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now