Array limits

Miscellaneous Forums/General Discussion/Array limits

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

"I think i misunderstand multidimentional arrays fullstop."

It's quite simple:

Dim A(5) creates the following, where each number is a single integer*:

[12345]

But Dim A(4,5) creates the following:

[12345][12345][12345][12345]

So you now have four sets of five integers.

And Dim A(3, 4, 5) creates this:

[12345][12345][12345][12345] [12345][12345][12345][12345] [12345][12345][12345][12345]

Which is three sets of four sets of five integers.

I think you can guess that Dim A(2,3,4,5) would do!

When you're working with multi dimensional arrays like this, the size increases greatly with each additional array element you add. Dim A(12, 12, 12, 12) will have 12^4 integers in it, or 12*12*12*12. That's 20736 integers, and I didn't increase the numbers very much from my examples above!


* In any language except Blitz that is. Blitz actually creates an extra element because beginners don't understand the concept of looping from 0 to SizeOfArray-1, and they try to start at 1 instead of 0. Personally I don't think Blitz should do this because it will just confuse people later.