Sign in to follow this  
Followers 0
=sinister=

Completely Stumbled On This Array?

3 posts in this topic

I have this array, I use the _ArraySearch() function, however, If it ever searches for the value 4, it returns 0, but it works for every other value (1-12)

#include <Array.au3>
$FretPositionsString1 = _ArrayCreate("1|1|40|16", "1|2|104|16", "1|3|160|16", "1|4|224|16", "1|5|280|16", "1|6|328|16", "1|7|376|16", "1|8|424|16", "1|9|464|16", "1|10|504|16", "1|11|552|16", "1|12|592|16")
;For this test, let $String = 1 and $Fret = 4
$String = 1
$Fret = 4
            $SearchPosition = _ArraySearch($FretPositionsString1, $String & "|" & $Fret, 0, 0, 0, True)
            MsgBox(0, "Test", $SearchPosition);<---- Always returns 0 for the value 4, but the correct value for every other value??

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your problem is: you have 2 matches in your array for the string you're searching for: "1|1|40|16" and "1|4|224|16"

Because the first array element has a match - _ArraySearch returns its index which is 0

Solution:

- search for a more complex match (like 1|4|2 ... or something else)

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Thanks for the reply, I'll probbly just use a different method (Using If's/Switch and the case command)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0