HeidiR Posted August 4, 2008 Share Posted August 4, 2008 If there an easy way to compare two 1D arrays similar to StringCompare ( "string1", "string2")? Like: ArrayCompare ($ar1, $ar2) HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/ Link to comment Share on other sites More sharing options...
Valuater Posted August 4, 2008 Share Posted August 4, 2008 Search help for any of these ;_ArrayAdd ;_ArrayBinarySearch ;_ArrayConcatenate ;_ArrayDelete ;_ArrayDisplay ;_ArrayFindAll ;_ArrayInsert ;_ArrayMax ;_ArrayMaxIndex ;_ArrayMin ;_ArrayMinIndex ;_ArrayPop ;_ArrayPush ;_ArrayReverse ;_ArraySearch ;_ArraySort ;_ArraySwap ;_ArrayToClip ;_ArrayToString ;_ArrayTrim 8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 4, 2008 Moderators Share Posted August 4, 2008 Search help for any of these;_ArrayAdd;_ArrayBinarySearch;_ArrayConcatenate;_ArrayDelete;_ArrayDisplay;_ArrayFindAll;_ArrayInsert;_ArrayMax;_ArrayMaxIndex;_ArrayMin;_ArrayMinIndex;_ArrayPop;_ArrayPush;_ArrayReverse;_ArraySearch;_ArraySort;_ArraySwap;_ArrayToClip;_ArrayToString;_ArrayTrim8)Or use the search feature on the forum? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
HeidiR Posted August 4, 2008 Author Share Posted August 4, 2008 Or use the search feature on the forum? Thanks for the info. I didn't find what I was looking for so I wrote my own (below). CODEFunc array_compare($ar1, $ar2) Local $str1="", $str2="" For $i = 0 to ubound($ar1) -1 $str1 &= $ar1[$i] Next For $i = 0 to ubound($ar2) -1 $str2 &= $ar2[$i] Next Return StringCompare($str1, $str2, 1) Endfunc HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/ Link to comment Share on other sites More sharing options...
-Ultima- Posted August 4, 2008 Share Posted August 4, 2008 (edited) You can probably do a bit better than that Func _ArrayStringCompare($avArray1, $avArray2, $iFlag = 0) Local $iUpper = UBound($avArray1) If UBound($avArray2) < $iUpper Then $iUpper = UBound($avArray2) Local $iCmp For $i = 0 To $iUpper - 1 $iCmp = StringCompare($avArray1[$i], $avArray2[$i], $iFlag) If $iCmp Then Return $iCmp Next Return 0 EndFunc Your method would fail on $avArray1 = ["a", "b"] $avArray2 = ["ab"] It would report the two arrays to be equal (they're not). Edited August 4, 2008 by -Ultima- [ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ] Link to comment Share on other sites More sharing options...
therks Posted August 5, 2008 Share Posted August 5, 2008 I wrote a set of functions for dumping information from variables a while ago. You can find it here. If you include that file, you can do something like this:#include <Variable.au3> $array = StringSplit('Hello', '') $array2 = StringSplit('Hello!', '') If _VarDump($array) == _VarDump($array2) Then ; Match EndIfI don't know how efficient that would be though.*Off topic note: _VarDump doesn't work on structs in the current version of AutoIt. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
HeidiR Posted August 5, 2008 Author Share Posted August 5, 2008 Thanks for the code suggestions guys! They were very helpful! :-) HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/ 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