The DIM is short for DIMension. This is used to define an array size. Okay let's back up for a minute. An array is a variable with and index number or numbers in parethesis which can have multiple dimesions or just a single dimesion.
Does this sound confusing? Let me explain more in detail.
Let say you have a list of names and you want to store them as a variable. You know what a variable is right? Well, okay. You could do the following...
name1$="Joe"
name2$="Dave"
name3$="Mike"
name4$="Steve"
Notice that I used four different variables to store the names. To make things easier and have fewer variables, you would use an ARRAY.
dim name$(4)
name$(1)="Joe"
name$(2)="Dave"
name$(3)="Mike"
name$(4)="Steve"
The code above uses only one variable indexed, in this case a single array variable, to store the names. This makes it easier than using multiple variables. The DIM statement was used to define and array size of 4 elements or names.
You might ask why would someone would want to use an ARRAY? Well for many reasons. What if there were more than four names, how about a hundred or a thousand? You wouldn't want to use that many variables to store each name. You would only need one, an array variable. This simplifies situations where you need to manipulate the data stored in an array.
dim names$(4)
for i=1 to 4
read names$(i)
print names$(i)
next i
data joe,dave,mike,steve
Mulitiple dimesions are possible too. Let's say you want to add a
last name. You could use a 2-dimensional array.
dim names$(4,2)
names$(1,1)="Joe"
names$(2,1)="Dave"
names$(3,1)="Mike"
names$(4,1)="Steve"
names$(1,2)="Thomas"
names$(2,2)="Jones"
names$(3,2)="Harris"
names$(4,2)="Roberts"
Or,
dim names$(4,2)
for i=1 to 4
for j=1 to 2
read names$(i,j)
print names$(i,j)
next j
next i
data Joe,Thomas,Dave,Jones,Mike,Harris,Steve,Roberts
You can have three, four, or more dimesions as well. Think of an array as a filing cabinet. Each drawer is an array variable. Each folder in that drawer is an element containing information concerning that array. In my example, that array was names$(4) or names$(4,2).
Does this answer you question?