Jump to content

trouble with simple array initialization


Burgs
 Share

Recommended Posts

Hello,

  OK and now for the simplest and dumbest question ever posted in this forum...I declare a 2 dimensional variable as so:

Global $_SAVED_PIX[1][1] = [[-1], [-1]]

  As can be seen I'm trying to initialize the two elements with an initial value of "-1"...why does AutoIT give me an "Array variable has incorrect number of subscripts or subscript dimension range exceeded" error...????  What is wrong with that code...???   It seems to fit perfectly with the syntax outlined in the manual.  Thanks in advance for any hint...regards

 

Link to comment
Share on other sites

this?

#include<array.au3>

Global $_SAVED_PIX[1][2] = [[-1, -1]]

_ArrayDisplay($_SAVED_PIX)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

That’s because you created an array with one row and one column resulting in a single „cell“. But you try to initialize two „cells“. Hence the error :) 

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

9 hours ago, Burgs said:

guess that makes sense

This is what you declared (fixing the # of rows)

#include<array.au3>

Global $_SAVED_PIX[2][1] = [[-1], [-1]]

_ArrayDisplay($_SAVED_PIX)

Which is a weird way to declare this:

#include<array.au3>

Global $_SAVED_PIX[2] = [-1, -1]

_ArrayDisplay($_SAVED_PIX)

and then post #2 is the 1 row 2 col solution...

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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