Sign in to follow this  
Followers 0
Vindicator209

subscript dimension range exceeded

6 posts in this topic

Sorry I'm new to this whole dimension thing, but whats wrong with this:

Dim $A[30][30]
For $x = 0 to 30
    For $y = 0 to 30
        $A[$x][$y] = GUICtrlCreatePic($Tiles & "Empty.bmp",$x * 25,$y *25,25,25)
    Next
Next

I figure its something with the Dim line


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites



Sorry I'm new to this whole dimension thing, but whats wrong with this:

Dim $A[30][30]
For $x = 0 to 30
    For $y = 0 to 30
        $A[$x][$y] = GUICtrlCreatePic($Tiles & "Empty.bmp",$x * 25,$y *25,25,25)
    Next
Next

I figure its something with the Dim line

You will probably have to change the dim to [31][31] But you should change

For $x = 0 to 30

to

For $x = 0 To Ubound($A)-1


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks... but what exactly doest that do?

Edited by VindicatorOmega

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

For $x = 0

Starts the iteration (loop) at 0,

To Ubound($A)-1

Iterates (loops) through values of x until it reaches Ubound($A)-1

Which is a way of determining the upper bound(the actual number of elements) of the array $A, minus one, so that you will never try to iterate through the loop more times than there are elements in the array.

Share this post


Link to post
Share on other sites

Ah, thanks.

I can't believe I dodn't look that up earlier, that would have helped me so much in other projects.. lol


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

If the first element contains Data and not the number of elements then you use Ubound. It depends on how the array is built. For example StringSplit uses Array[0] to hold the number of elements so you can use For $I = 1 To array[0] or if the number of elements is known you can use For $I = 1 To Number of Elements.

In all situations you can use Ubound(Array) -1. The onnly thing that may change is the first element that contains data. It could be either 1 or 0.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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