NileshSutar Posted September 24, 2013 Posted September 24, 2013 Hi guys, i want to compare two "2D" arrays such that it should return 0 if no element is common and 1 if one or more elements are common.How can i do that.???
FireFox Posted September 24, 2013 Posted September 24, 2013 Hi, Nested For. Think in your head how you would do it and then translate it, quite easy. Br, FireFox.
NileshSutar Posted September 24, 2013 Author Posted September 24, 2013 i have done it> but the arrays come from different function.How can i import them in my compare function
FireFox Posted September 24, 2013 Posted September 24, 2013 Post your code, so we can see what you're talking about Br, FireFox.
water Posted September 24, 2013 Posted September 24, 2013 Define both arrays by using Global to make them available for every function. 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
Gianni Posted September 24, 2013 Posted September 24, 2013 (edited) Assuming both arrays has the same number of elements, something like this should work Func Compare2D(ByRef $Array1, ByRef $Array2) Local $Check = 0 For $x = 0 To UBound($Array1, 1) -1 For $y = 0 To UBound($Array1, 2) -1 $Check += ($Array1[$x][$y] = $Array2[$x][$y]) Next Next $Check = $Check > 0 Return $Check EndFunc ;==>Compare2D (not tested) bye edit added -1 to ubound in listing Edited September 24, 2013 by PincoPanco Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
NileshSutar Posted September 24, 2013 Author Posted September 24, 2013 Define both arrays by using Global to make them available for every function. Worked thanks
AZJIO Posted September 24, 2013 Posted September 24, 2013 First check that the dimensions of the array are the same. Make "ExitLoop" out of the loop if the going does not match. I don't think that should be checked until the end, if the first cell is not the same. My other projects or all
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