Sign in to follow this  
Followers 0
barbossa

Error Initializing 5D Array

12 posts in this topic

Hi!

I was messing around with AutoIT, and found I can't initialize a 5D array. I re-checked the square brackets countless times, but AutoIT keeps returning "ERROR: wrong nesting in initializer". 4D arrays work fine.

Here is the example:

Local $arTestOk[2][2][2][2] = [[[[0,0],[0,0]],[[0,0],[0,0]]],[[[0,0],[0,0]],[[0,0],[0,0]]]]
Local $arTestBad[2][2][2][2][2] = [[[[[0,0],[0,0]],[[0,0],[0,0]]],[[[0,0],[0,0]],[[0,0],[0,0]]]],[[[[0,0],[0,0]],[[0,0],[0,0]]],[[[0,0],[0,0]],[[0,0],[0,0]]]]]

Is this a bug with AutoIT?

Share this post


Link to post
Share on other sites



According to the documentation the maximum number of subscripts (dimensions) for an array is 64.

So there must be something wrong with the brackets.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

That is the problem: the brackets ARE correct.

Try running this:

Dim $arTest[1][1][1][1][1] = [[[[[1]]]]]

Share this post


Link to post
Share on other sites

barbossa,

Before I spend any time on this problem - does it have a real-world application or are you just playing about? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Beside that it is true that the brackets seems to be ok, how do you want to handle a 5D array?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Just letting you know, the brackets are probably fine, but you don't have enough numbers for a 5D array, you've only got sets of 0's, that's fine for a 4D array, but you're missing the 5th dimension.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

As I said in the first post, I was just playing around the possibility, I don't think it would have any practical application, and would definitely be horrendous to maintain.

BrewManNH, look at the 1-sized example I posted after. It has 5 dimensions, and holds only one value (the number of values would be 1^5 = 1). The first example has 32 zeros, filling the entire array (2^5 = 32).

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Looks like you will need to do 4d arrays, nested with 2d arrays :)

edit, make that 1d arrays as the nested...hard to conceptualize

Local $arraySub[2] = [0, 1]
Local $arraySub2[2] = [2, 3]
Local $array[2][2][2][2] = [[[[$arraySub,$arraySub2],[$arraySub,$arraySub2]],[[$arraySub,$arraySub2],[$arraySub,$arraySub2]]],[[[$arraySub,$arraySub2],[$arraySub,$arraySub2]],[[$arraySub,$arraySub2],[$arraySub,$arraySub2]]]]
For $i = 0 To UBound($array) - 1
 For $j = 0 To UBound($array, 2) - 1
  For $k = 0 To UBound($array, 3) - 1
   For $l = 0 To UBound($array, 4) - 1
    $tempArray = $array[$i][$j][$k][$l]
    For $m = 0 To UBound($tempArray) - 1
     ConsoleWrite("$array[" & $i & "][" & $j & "][" & $k & "][" & $l & "].[" & $m & "] = " & $tempArray[$m] & @CRLF)
    Next
   Next
  Next
 Next
Next

output:

$array[0][0][0][0].[0] = 0

$array[0][0][0][0].[1] = 1

$array[0][0][0][1].[0] = 2

$array[0][0][0][1].[1] = 3

$array[0][0][1][0].[0] = 0

$array[0][0][1][0].[1] = 1

$array[0][0][1][1].[0] = 2

$array[0][0][1][1].[1] = 3

$array[0][1][0][0].[0] = 0

$array[0][1][0][0].[1] = 1

$array[0][1][0][1].[0] = 2

$array[0][1][0][1].[1] = 3

$array[0][1][1][0].[0] = 0

$array[0][1][1][0].[1] = 1

$array[0][1][1][1].[0] = 2

$array[0][1][1][1].[1] = 3

$array[1][0][0][0].[0] = 0

$array[1][0][0][0].[1] = 1

$array[1][0][0][1].[0] = 2

$array[1][0][0][1].[1] = 3

$array[1][0][1][0].[0] = 0

$array[1][0][1][0].[1] = 1

$array[1][0][1][1].[0] = 2

$array[1][0][1][1].[1] = 3

$array[1][1][0][0].[0] = 0

$array[1][1][0][0].[1] = 1

$array[1][1][0][1].[0] = 2

$array[1][1][0][1].[1] = 3

$array[1][1][1][0].[0] = 0

$array[1][1][1][0].[1] = 1

$array[1][1][1][1].[0] = 2

$array[1][1][1][1].[1] = 3

last modification...displaying the full fill

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

AU3Check problem? It executes correct if you launch ouside of SciTE.

Local $arTestBad[2][2][2][2][2] = [[[[[0,0],[0,0]],[[0,0],[0,0]]],[[[0,0],[0,0]],[[0,0],[0,0]]]],[[[[0,0],[0,0]],[[0,0],[0,0]]],[[[0,0],[0,0]],[[0,0],[0,0]]]]]

$arTestBad[0][1][0][0][1] = Random(0, 100, 1)

MsgBox(0x40000, '5D Array', '$arTestBad[0][1][0][0][1] = ' & $arTestBad[0][1][0][0][1])

Share this post


Link to post
Share on other sites

I can't even imagine the use for a 5D array, but it's an interesting mind bender to get my head around the bracket and comma placements.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Tekk,

probably that, tested it too and the compiled .exe worked fine...

jdelany,

well done!

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

I just checked and AutoIt will work correctly with 10D arrays and more, unless Au3Check is invoked and the explicitely initialized. So this is a an Au3Check bug.

In fact that post drew my attention on a point that escaped me until today, and probably devs themselves.

The doc says the maximum dimension of an array is 64 but in fact the actual maximum "non nonsense" dimension is much less:

Local $arTestBad[2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2]

is a valid 23D array declaration but adding one more dimension result in hitting another limit: the maximum size of an array:

"C:UsersjcDocumentsAutoMATTestNestedFor.au3" (7) : ==> Array maximum size exceeded.:

Local $arTestBad[2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2]

Local $arTestBad[2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][2][^ ERROR

Hence the maximum practical dimension of an array is 24, well, unless you use dummy dimensions like [1][1]... which don't bring you anything useful.

I'm openning two distinct trac tickets on these points.

As a [mathematically inclined] sidenote, a 24D object is enough to represent the Leech lattice, which makes this singular object appear once more in an area where it was not expected.

EDIT: I checked that 64 dimensions are actually the hard limit, albeit useless:

Local $arTestGood[1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1]

works but is likely to use L.I.S.P. (Lots of Insipide Square Parenthesis) uselessly!

Edited by jchd
1 person likes this

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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