Jump to content

Recommended Posts

Posted

With _arraysearch you can only search in columns, see example from helptext.

Is it possible to search in rows?

For example how do i find value 3 in row 3?

CODE
#include

#include

#include

#include

Local $avArray[6][2] = [ _

["String0", "SubString0"], _

["String1", "SubString1"], _

["String2", "SubString2"], _

["String3", "SubString3"], _

["String4", "SubString4"], _

["String5", "SubString5"]]

_ArrayDisplay($avArray, "$avArray")

$sSearch = InputBox("_ArraySearch() demo", "String to find?")

If @error Then Exit

$sColumn = InputBox("_ArraySearch() demo", "Column to search?")

If @error Then Exit

$sColumn = Int($sColumn)

$iIndex = _ArraySearch($avArray, $sSearch, 0, 0, 0, 1, $sColumn)

If @error Then

MsgBox(0, "Not Found", '"' & $sSearch & '" was not found on column ' & $sColumn & '.')

Else

MsgBox(0, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.')

EndIf

My scripts: _ConsoleWriteLog | _FileArray2D

 

 

 

Posted

You are mixed up, _ArraySearch is for one dimensional arrays, meaning it only searches rows. You need a search that checks each column in every row.

The next question is, what do you want returned? You will almost have to return a two element array with the row in the first element and the column in the second element.

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
  • Recently Browsing   0 members

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