SpookMeister Posted September 13, 2005 Share Posted September 13, 2005 Is there a way to compare multi-dimentional arrays as a whole, without itterating through the array? Something like this: (which doesnt work BTW) expandcollapse popupHotKeySet("{ESC}", "Terminate") HotKeySet("{F5}", "compare") HotKeySet("{F6}", "changeA") HotKeySet("{F7}", "changeB") Global $testA[3][3] Global $testB[3][3] For $x = 0 to 2 for $y = 0 to 2 $testA[$x][$y]=111 $testB[$x][$y]=111 Next Next while 1 Sleep(1000) WEnd Func compare() If $testA = $testB Then MsgBox(0,"Compare","They are the same") Else MsgBox(0,"Compare","They do not match") EndIf EndFunc Func changeA() $testA[1][1]=121 EndFunc Func changeB() $testA[1][1]=111 EndFunc Func Terminate() Exit EndFunc [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
/dev/null Posted September 13, 2005 Share Posted September 13, 2005 Is there a way to compare multi-dimentional arrays as a whole, without itterating through the array?Sorry, no way, other than to loop through the array and compare values.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Nutster Posted September 14, 2005 Share Posted September 14, 2005 Currently, there is no built-in feature for comparing arrays, other than looping through and comparing element by element.What would the requirements for equality be?Same number of dimensionsEach dimension is the same sizeSame contents for corresponding elementsAt different times, it is important to know which of these conditions failed. Just asking $a = $b doesn't let you know why it failed. You can check that when you are doing the looping to compare.Well, I guess I could write something like, but it is not my highest priority right now. Work, bug fixes, Work AutoIt debugger, etc. Hmm I do have Variant rewrite on my to-do list. Maybe I can sneak it in there. This may show up in the beta, but do not expect it for a while. David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
seandisanti Posted September 14, 2005 Share Posted September 14, 2005 Is there a way to compare multi-dimentional arrays as a whole, without itterating through the array?Something like this: (which doesnt work BTW)expandcollapse popupHotKeySet("{ESC}", "Terminate") HotKeySet("{F5}", "compare") HotKeySet("{F6}", "changeA") HotKeySet("{F7}", "changeB") Global $testA[3][3] Global $testB[3][3] For $x = 0 to 2 for $y = 0 to 2 $testA[$x][$y]=111 $testB[$x][$y]=111 Next Next while 1 Sleep(1000) WEnd Func compare() If $testA = $testB Then MsgBox(0,"Compare","They are the same") Else MsgBox(0,"Compare","They do not match") EndIf EndFunc Func changeA() $testA[1][1]=121 EndFunc Func changeB() $testA[1][1]=111 EndFunc Func Terminate() Exit EndFunc<{POST_SNAPBACK}>if you're comparing to see if the arrays are exactly the same, i remember a while back someone made a UDF that works like _ArrayToString() to convert a multidimensional array to a string... you could find that UDF (i know i saw it in this forum, but they may have posted a finished product in scripts and scraps also) and convert both arrays to strings then compare the strings. Link to comment Share on other sites More sharing options...
SpookMeister Posted September 14, 2005 Author Share Posted September 14, 2005 (edited) if you're comparing to see if the arrays are exactly the same, i remember a while back someone made a UDF that works like _ArrayToString() to convert a multidimensional array to a string... you could find that UDF (i know i saw it in this forum, but they may have posted a finished product in scripts and scraps also) and convert both arrays to strings then compare the strings.<{POST_SNAPBACK}>Thanks!! that comment gave me the idea I needed. Edited September 14, 2005 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
seandisanti Posted September 14, 2005 Share Posted September 14, 2005 Thanks!! that comment gave me the idea I needed. <{POST_SNAPBACK}>cool, glad i could help. 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