I still don't get it...

BlitzPlus Forums/BlitzPlus Programming/I still don't get it...

Here is what I think the best and most easily comprehended explanation anyone has ever given.

Basically, Dim MyVar(4) would be a substitute for writing MyVar0=0:MyVar1=0:MyVar2=0:MyVar3=0:MyVar4=0 .

Using an array (which is what Dim creates) only saves you the huge hassle of making a long list of integers each serving a similar purpose and makes going through them much easier too.

My most common use for Dim arrays is tilemaps. Arrays can also be multidimensional, which means instead of having one number (Dim Var(X)) you can have two or even more numbers in the parentheses (Dim Var(X,Y)).

To use an array as a field for a type, simply use brakets [] rather than parentheses () when referring to it. For example, Type Obj:Field Array[7]:End Type

Another good thing to know, is that when you define an array with 5 in the parentheses, there are actually 6 numbers; Var(0) is also a valid variable.

When you try to access an array number that's out of the created range, you get an irritating error. Like, if you had Dim Array(6) and tried to reference to a variable Array(7) you'd end up getting an error.

To cycle through all your variables and do something to each one of them, use a for loop. For x=0 to 5:Array(x)=Array(x)+1:Next

I hope that helped, that's all the basics for Dim arrays.