Computersight > Programming > Blitz

Arrays in Blitz

A tutorial on arrays in BlitzBasic.

Alright, basically an array is a series of variables that are stored together, so you don't have to declare hundreds of variables. Here's an example:

Dim characters(5) ; this part declares the array

characters(0) = 54
characters(1) = 54
characters(2) = 54
characters(3) = 54
characters(4) = 54

As you can see it really is quite a simple concept. All you do is declare how many variables you want with Dim “variablename”(“number of variables”). Then you declare them. Now this didn't look very fast, but with loops, you can do it much faster, you'll learn that later, for now, just understand arrays.

Well, arrays don't just stop in one dimension, arrays can be multi-dimensional, this means that arrays can have more than one column of variables.

The column part probably caught you off guard. In arrays, it is best to think of them as columns and rows.

Anyhow, when you declare he array, you can add another parameter to the Dim function, which makes the array 2D. Like this.

Dim characters(5,2)
Now you have an array that can call up to ten character attributes, whatever they might be. This is because you have two rows of five. It looks a lot like this:

attribute attribute attribute attribute attribute

attribute attribute attribute attribute attribute

Arrays really can be useful in your programming, but if you have trouble understanding them, there is often a way around it. However, the loops in the next chapter you must understand.

By the way, now that were in too counting with the computer, I would like to point out something about computers. When counting with a computer, it will always start at zero. Because of this, certain things you must remember to start at zero, specifically array variables right now.

0
Liked It
I Like It!
Related Articles
Variables in Blitz  |  Loops in Blitz
Comments (0)
Post Your Comment:
Name:  
Copy the code into this box:  
Post comment with your Triond credentials?
Inside Computersight

Communication & Networks

 /

Computers

 /

Hardware

 /

Operating Systems

 /

Programming

 /

Software


Popular Tags
Popular Writers
Powered by
Computersight
About Us
Terms of Use
Privacy Policy
Services
Submit an Article
Advertise with Us
Contact

© 2007 Copyright Stanza Ltd. All Rights Reserved.