Jump to content

Filling multiple dimensional arrays


Recommended Posts

Extrapolating what's in the help file, I would expect this to work, but is says "syntax error".

local $var[5,5,7]

$var[0,0] = [1,2,3,4,5,6,7]

$var[0,1]= [7,6,5,4,3,2,1]

etc.

My $var array is loaded once, so I suppose I could read a file or something, but the above seemed so straightforward.

BTW, this doesn't work either, which is a nearly direct quote from help:

$local $days[7]

$days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]

but this does, so maybe my help file is out-of-date?

local $days[7] = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]

 

 

 

Link to comment
Share on other sites

You define $var as a 1D array but you specify 2 dimensions on your assignment statements.

$local is wrong - remove the $ sign.

Edited by water
Updated to make my post correct 😃

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

In fact, if you want to declare a 3D array you need to use :

Local $var[5][5][7]

If you want to assign a value to a specific cell, you need to use :

$var[0][1][5] = "A value"

If you want to instantiate a 3D array, you would need to use :

Local $var[5][5][7] = [[[1,2,3,4,5,1,2], [6,7,8,9,0,1,2]]] ; partly instantiated

Obviously, you are mixing how to declare an array and how to instantiate it.  Please review help file and wiki to better understand how arrays are functioning in AutoIt.

Link to comment
Share on other sites

To transform a string into an Array please have a look at function StringSplit.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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