faustf Posted November 27, 2019 Share Posted November 27, 2019 hi guys i want compare a 2D dimentional array , i saw some post here , i try to applicate but ,not go o_O.... sorry this is my script expandcollapse popup#include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <GuiStatusBar.au3> Local $aLBuyAndPrice[5][2] _ArrayDisplay($aLBuyAndPrice, 'primo array') Local $aLBuyAndPriceTwin[5][2] $sFill = "29|58.20" _ArrayAdd($aLBuyAndPriceTwin, $sFill) _ArrayDisplay($aLBuyAndPriceTwin, 'secondo array') Local $aL2Diff = _Array2DdifSort($aLBuyAndPrice, $aLBuyAndPriceTwin) _ArrayDisplay($aL2Diff, 'diff array') Func _Array2DdifSort($aArrayOne_2D, $aArrayTwo_2D) #cs For $iI = UBound($aArrayOne_2D) - 1 To 0 Step -1 For $j = UBound($aArrayTwo_2D) - 1 To 0 Step -1 If $aArrayOne_2D[$iI][1] = $aArrayTwo_2D[$j][1] Then ;_ArrayDelete($aArray, $iI) $aArrayOne_2D[$iI][1] = "" EndIf Next Next ; _ArrayDisplay($aArrayOne_2D) ;after comparison with assigning blanks For $iI = UBound($aArrayOne_2D) - 1 To 0 Step -1 If $aArrayOne_2D[$iI][1] = "" Or $aArrayOne_2D[$iI][1] = "E" Then _ArrayDelete($aArrayOne_2D, $iI) Next ; _ArrayDisplay($aArrayOne_2D) ;after deleting blanks and "E" Return $aArrayOne_2D #ce For $i = UBound($aArrayOne_2D) - 1 To 0 Step -1 For $j = UBound($aArrayTwo_2D) - 1 To 0 Step -1 If $aArrayOne_2D[$i][1] = $aArrayTwo_2D[$j][1] Or $aArrayOne_2D[$i][1] = "E" Then _ArrayDelete($aArrayOne_2D, $i) ExitLoop EndIf Next Next Return $aArrayOne_2D EndFunc ;==>_Array2DdifSort anyone can help me?? thankz alot Link to comment Share on other sites More sharing options...
seadoggie01 Posted November 27, 2019 Share Posted November 27, 2019 You can open the Array.au3 include file and take a look at _ArraySort if you're wanting to sort them like you're function says. If you do actually mean compare them, then you'll need to be a bit more specific about what exactly you want to compare in the arrays All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
faustf Posted November 27, 2019 Author Share Posted November 27, 2019 i want compare if not exist $sFill = "29|58.20" in first array return value Link to comment Share on other sites More sharing options...
ScrapeYourself Posted November 27, 2019 Share Posted November 27, 2019 Hello Faustf, Included is a 2darray_compare_2darray function. Hope it helps. Link to comment Share on other sites More sharing options...
faustf Posted November 27, 2019 Author Share Posted November 27, 2019 thankz i will look , i try to resolve in this moment with this solution but also in this mode not work not return me a value in if #include <Array.au3> #include <Color.au3> #include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <GuiStatusBar.au3> Local $aLBuyAndPrice[5][2] _ArrayDisplay($aLBuyAndPrice, 'primo array') Local $aLBuyAndPriceTwin[5][2] $sFill = "29|58.20" _ArrayAdd($aLBuyAndPriceTwin, $sFill) _ArrayDisplay($aLBuyAndPriceTwin, 'secondo array') ;Local $aL2Diff = _Array2DdifSort($aLBuyAndPrice, $aLBuyAndPriceTwin) Local $aL2Diff = _de($aLBuyAndPrice, $aLBuyAndPriceTwin) ;Local $aL2Diff = _Array2DdifSortP($aLBuyAndPrice, $aLBuyAndPriceTwin) _ArrayDisplay($aL2Diff, 'diff array') Func _de($aArrayOne_2D, $aArrayTwo_2D) Local $sLArray1 = _ArrayToString($aArrayOne_2D) Local $sLArray2 = _ArrayToString($aArrayTwo_2D) If StringCompare($sLArray1, $sLArray2) <> 0 Then For $i = 0 To UBound($sLArray2) - 1 If $sLArray2[$i] <> "" Then ConsoleWrite("val " & $sLArray2[$i] & @CRLF) EndIf Next EndIf EndFunc ;==>_de o_O Link to comment Share on other sites More sharing options...
iamtheky Posted November 27, 2019 Share Posted November 27, 2019 (edited) how about with an example everyone can use? Is this close? #include<array.au3> local $a[2][3] = [['1','2','3'] , ['4','5','8']] local $b[2][3] = [['7','8','9'] , ['1',"A","B"]] ;~ _ArrayDisplay($a) ;~ _ArrayDisplay($b) For $i = 0 to ubound($a) - 1 For $k = 0 to ubound($a , 2) - 1 For $j = 0 to ubound($b) - 1 For $l = 0 to ubound($b , 2) - 1 If $a[$i][$k] = $b[$j][$l] Then msgbox(0, 'match' , "$a[" & $i & "][" & $k & "] = $b[" & $j & "][" & $l & "]") Next Next Next Next edit: I had copied a bad character, your above example is now firing. I will populate mine with similar strings Edited November 27, 2019 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
faustf Posted November 28, 2019 Author Share Posted November 28, 2019 thankz your prog work but ,probably i explain problem not so good . scenario: you read a data in real time from sensor and return this value valore 34--57,97 valore 61--57,96 valore 61--57,96 valore 34--57,97 valore 34--57,97 valore 61--57,96 valore 61--57,96 i want in real time , if arrive a first time 34--57.97 print , but when arrive the second time not print it in this mode the list upper will be valore 34--57,97 valore 61--57,96 i try with compare 2 array 2D but when shift second to first and in second load data like startfirst, it print it how is possible remove this bug? thankz Link to comment Share on other sites More sharing options...
Nine Posted November 28, 2019 Share Posted November 28, 2019 Maybe this : #include <Constants.au3> #include <Array.au3> Opt ("MustDeclareVars", 1) Local $aValueRead[0], $sValue While True $sValue = ReadSensor () If @error Then ExitLoop _ArraySearch ($aValueRead, $sValue) If @error Then _ArrayAdd ($aValueRead, $sValue) WEnd _ArrayDisplay ($aValueRead) ;this function needs to be rewritten to get your sensor values Func ReadSensor () Local Const $aSensor [] = [7, _ "valore 34--57,97", _ "valore 61--57,96", _ "valore 61--57,96", _ "valore 34--57,97", _ "valore 34--57,97", _ "valore 61--57,96", _ "valore 61--57,96" ] Local Static $iInd = 0 $iInd += 1 If $iInd > $aSensor[0] Then Return SetError (1) Return $aSensor[$iInd] EndFunc “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
faustf Posted November 28, 2019 Author Share Posted November 28, 2019 yea work good , why you choice _arraysearch and not arrybinarysearch ? and 2 questions is possible detect if an array pass at the functions is monodimentional or bidimentional?? thankz again Link to comment Share on other sites More sharing options...
faustf Posted November 28, 2019 Author Share Posted November 28, 2019 i answer me at second questions ubound with option 2 thankz at all again Link to comment Share on other sites More sharing options...
Musashi Posted November 28, 2019 Share Posted November 28, 2019 1 hour ago, faustf said: why you choice _arraysearch and not arrybinarysearch ? The reason for this can possibly be found in the remarks of the frequently cited AutoIt-Help . -> _ArraySearch : ... is useful when the array cannot be sorted before the search. -> _ArrayBinarySearch : When performing a binary search on an array of items, the array (specified column if 2D) MUST be sorted in ASCENDING order before the search is done. Otherwise undefined results will be returned. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
jchd Posted November 28, 2019 Share Posted November 28, 2019 You don't explain your context well enough. You get input from a number of data capture devices. How many devices you're having to deal with is an important information (5 isn't the same as tens of thousands). You store this data and I expect that there is a device identifier in your input stream (maybe 34 & 61 in your examples). Along with device ID you also get measure data (I guess it's 57,97 & 57,96 in your examples). You say "real time" but give no clue about how fast you're obtaining data and how fast you want it processed. You don't want to store duplicate measurements from the same device. OK till there. Now I still have questions to provide a useful, practical answer: 1) Are you interested in keeping the order of arrival of distinct data from every device (then you need to store precise time of arrival as well) or 2) Are you just interested in storing the various distinct measures obtained by each device, independant of the moment they were sampled? 3) How many distinct measures are you going to collect during the run of the program (dozens, billions)? 4) Are you processing the data while it accumulates? For instance, 1) would allow you to represent a graph of the variation of measures (time, value) for each device, but 2) would say nothing about when a pathological measurement occured. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
faustf Posted November 28, 2019 Author Share Posted November 28, 2019 1 data is not fundamental but if exist why not 2 no 3 1 milion for a day maybe, but in this milion i have 2/3 duplicate data 4 yes is necessary elaborate in realtime and excluding duplicated data (the velocity is variable some time is very fast change digit under seconds some time change digit after one minuts) Link to comment Share on other sites More sharing options...
jchd Posted November 28, 2019 Share Posted November 28, 2019 Then I would use SQLite to store and retrieve the data, without one second of hesitation. That will also make later processing the data (statistics or detailed analysis) much easier. Musashi 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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