Shane0000 Posted July 20, 2014 Posted July 20, 2014 (edited) Local $aArray_1[3] = [0,'x',2] $a1 = Execute('$aArray_' & 1 ) If @error Then Msgbox(0,@error,'Execute not working') _ArrayDisplay($a1) $i1 = _ArraySearch($a1,'y') If @error Then Msgbox(0,@error,'not working - 0') ConsoleWrite('$i1: ' & $i1 & @CRLF) $i1 = _ArraySearch($a1,'x') If @error Then Msgbox(0,@error,'not working - 1') ConsoleWrite('$i1: ' & $i1 & @CRLF) $i1 = _ArraySearch($aArray_1,'y') If @error Then Msgbox(0,@error,'not working - 2') ConsoleWrite('$i1: ' & $i1 & @CRLF) $i1 = _ArraySearch($aArray_1,'x') If @error Then Msgbox(0,@error,'not working - 3') ConsoleWrite('$i1: ' & $i1 & @CRLF) Im not sure what is going on in the above example. _ArraySearch should return a -1 if the item searched for is not found, however : _ArraySearch returns a 0 when searching for 'y' in the above array. [0,'x',2] _ArraySearch returns a 0 when searching for 'x' even tho 'x' resides in row 1 Also referencing the $aArray_1 variable returns the same 0 from _ArraySearch both times. No @error codes are set off either. What am I missing here ? ThanksĀ Edited July 20, 2014 by Shane0000
Solution autoitter Posted July 20, 2014 Solution Posted July 20, 2014 It looks like this has something to do with the mixed type of elements in your array. It works if you set theĀ $iCompare flag in the call to _ArraySearch to a value of 2.
Shane0000 Posted July 20, 2014 Author Posted July 20, 2014 Ahh thanks I reread the help file and see that the default turns a string to = 0. Thanks
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