Jump to content

Completely Stumbled On This Array?


Recommended Posts

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??
Link to comment
Share on other sites

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 :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...