Jump to content

Recommended Posts

Posted (edited)

How do I work with 2D arrays.  I've tried this but get errors.

Local $aTest[4][4] = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]

;$aTest[0][] = [10,11,12]  ; Error at []

Local $sTest = ""
For $i = 0 To UBound($aTest)-1
  Local $aExtract = _ArrayExtract($aTest,$i,$i)
  $sTest = $sTest & MyTest($aExtract)
Next
Func MyTest($aTemp)
  _ArrayDisplay($aTemp)
  ; Error at    v $aTemp
  Return String($aTemp[0]) & " - " & String($aTemp[1]) & " - " & String($aTemp[2]) & @CRLF
EndFunc

 

 

Edited by TheWizEd
Posted

A very good tutorial in the wiki explains how to work with arrays: https://www.autoitscript.com/wiki/Arrays

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

For a 2d Array I always think of it like $aArray[Row][Column] like in the table below:

Col Col Col Col
            [0] [1] [2] [3]
---------------------------
Row [0] |    0   1   2   3
Row [1] |    0   1   2   3
Row [2] |    0   1   2   3
Row [3] |    0   1   2   3

 

Posted

Thanks for all the advise.  It took a while but I think i've figured out arrays. 

Now how about maps.  I get error "Variable subscript badly formatted" at [].

Local $mTest[]
$mTest["one"] = 1
$mTest["two"] = 2
$mTest["three"] = 3

Posted

Which version of AutoIt do you run?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

IIRC Maps only work with the latest beta version 3.3.15.0.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 2/11/2018 at 2:48 PM, water said:

IIRC Maps only work with the latest beta version 3.3.15.0.

Expand  

Thanks.  The docs and change log are misleading.  I was searching change log for mention of map and it implies maps are available 3.3.14.0 #2502.

Luckily I found example of using Scripting.Dictionary.

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
×
×
  • Create New...