Sign in to follow this  
Followers 0
eignxing

multi dimension array search from help file

4 posts in this topic

This does not seem to work for me and I'm feeling slow today. I just modified parts of the help file. What am I doing wrong?

#include <Array.au3>

;===============================================================================
; Example 2 (using a 2D array)
;===============================================================================
Local $avArray[6][2] = [ _
["String0", "2009/03/24 12:34:25"], _
["String1", "2009/03/25 11:34:25"], _
["String2", "asdf"], _
["String3", "2009/07/01 12:34:25"], _
["String4", "2009/06/12 12:34:25"], _
["String5", "2009/07/07 00:48:23"]]

_ArrayDisplay($avArray, "$avArray")

$sColumn = 1

$iIndex = _ArraySearch($avArray, "asdf", 0, 0, 0, 1, $sColumn)
If @error Then
    MsgBox(0, "Not Found", '"' & "asdf" & '" was not found on column ' & $sColumn & '.')
Else
    MsgBox(0, "Found", '"' & "asdf" & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.')
EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The help file is wrong. I don't know if it is because of an update, but the example is missing a parameter. Before $sColumn, you need another parameter with a value of 1. This is the correct syntax for the example in the help file.

#include <Array.au3>
 ;===============================================================================
 ; Example 2 (using a 2D array)
 ;===============================================================================
 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, 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
Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Nice to know, thanks!

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