# two dimenstional aray search

## Recommended Posts

How do I do a two dimensional array search?

Is there a way to load the array in on line

ie \$Array[0][0] = "String0","apple"

_ArraySearch

#Include<Array.au3>

Dim \$Array[6][2]

\$Array[0][0] = "String0"

\$Array[1] [0]= "String1"

\$Array[2] [0]= "String2"

\$Array[0][1] = "apple"

\$Array[1] [1]= "orange"

\$Array[2] [1]= "pear"

\$Input = InputBox("ArraySearch Demo", "String To Find?")

If @error Then Exit

\$Pos = _ArraySearch (\$Array, \$Input, 0, 0, 0, True)

Select

Case \$Pos = -1

Case Else

MsgBox(0, "Found", '"' & \$Input & '" was found in the array at pos ' & \$Pos & ".")

EndSelect

##### Share on other sites

Try this:

```Dim \$Array[6][2]
\$Array[0][0] = "String0"
\$Array[1] [0]= "String1"
\$Array[2] [0]= "String2"

\$Array[0][1] = "apple"
\$Array[1] [1]= "orange"
\$Array[2] [1]= "pear"

\$Input = InputBox("ArraySearch Demo", "String To Find?")
If @error Then Exit

For \$x = 0 to UBound(\$Array,1) -1
For \$y = 0 to Ubound(\$Array,2) -1
If StringInStr(\$Array[\$x][\$y],\$Input) > 0 Then
msgbox(0,"","Item found in Array[" & \$x & "][" & \$y &"]")
EndIf
Next
Next```
Edited by covaks
##### Share on other sites

Is there a way to load the array in on line

ie \$Array[0][0] = "String0","apple"

Dim \$Array[6][2]

\$Array[0][0] = "String0"

\$Array[1] [0]= "String1"

\$Array[2] [0]= "String2"

\$Array[0][1] = "apple"

\$Array[1] [1]= "orange"

\$Array[2] [1]= "pear"

`Global \$Array[6][2] = [["String0", "apple"], ["String1", "orange"], ["String2", "pear"]]`

One "row" of data in each inner set of square brackets.

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...