Jump to content

Recommended Posts

Posted

Hi All,

I have a problem. Can you return a value from an _ArraySearch? 
Below is from the help file. Basically, is it possible to get the value in the next column which is #33???

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray[6][4]
For $i = 0 To 5
    For $j = 0 To 3
        $aArray[$i][$j] = "#" & $i & $j
    Next
Next
_ArrayDisplay($aArray, "Looking for '#32'", Default, 8)
Local $list
; Search by column (looking in col 2)
Local $iIndex = _ArraySearch($aArray, "#32", 0, 0, 0, 0, 1, -1)
MsgBox($MB_SYSTEMMODAL, "Found '#32'", "Column 2 on Row " & $iIndex)

 

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Posted

So I found a method of doing this and will leave this post open, because there maybe a better way of doing this.

 

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray[6][4]
For $i = 0 To 5
    For $j = 0 To 3
        $aArray[$i][$j] = "#" & $i & $j
    Next
Next
_ArrayDisplay($aArray, "Looking for '#32'", Default, 8)
Local $list
; Search by column (looking in col 2)
Local $iRow = _ArraySearch($aArray, "#32", 0, 0, 0, 0, 1, -1, False) ; Search per row
Local $iColumn = _ArraySearch($aArray, "#32", 0, 0, 0, 0, 1, -1, True) ; Search per Column

MsgBox($MB_SYSTEMMODAL, "Found '#32'", "Column 2 and the value is  " & $aArray[$iRow][$iColumn])

 

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Posted

No need to search the whole array after first search :

#include <Array.au3>
#include <MsgBoxConstants.au3>

Local $aArray[6][4]
For $i = 0 To 5
    For $j = 0 To 3
        $aArray[$i][$j] = "#" & $i & $j
    Next
Next
_ArrayDisplay($aArray, "Looking for '#32'", Default, 8)
Local $iLine = _ArraySearch($aArray, "#32")
Local $iCol = _ArraySearch($aArray, "#32", 0, 0, 0, 0, 1, $iLine, True)
MsgBox($MB_SYSTEMMODAL, "Found '#32'", $iLine & "/" & $iCol)

 

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...