Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / I am new to this whole programing. I need help with ARRAYS!

Author
Message
Iron Maiden
20
Years of Service
User Offline
Joined: 27th Dec 2004
Location:
Posted: 27th Dec 2004 10:56
I just got the book, "Begginner's Guides to Darkbasic Game Programming" for Christmas from my brother and I got the Trial with the CD and I am stumped in how and what ARRAYS do. Someone help a newbie out! ::GASPS::
Iron Maiden
20
Years of Service
User Offline
Joined: 27th Dec 2004
Location:
Posted: 27th Dec 2004 12:02
Sorry, I didn't know about the New Comers forum. I also posted there too. I guess you can ignore this one.
hyrichter
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 27th Dec 2004 12:16
Arrays are useful for holding multiple values with the same variable name. Say for example you wanted to keep track of the weight of 30 people in your class. Using normal variables, you'd need 30 variables to keep track of all this information, and it'd be hard to keep track of them. A better way is to use an array to store this information.

Now, here's how an array works...

First you must dimension your array. This means you tell the computer how many items of data you think you'll need. Like this:

dim MyArray(29)

That will hold 30 items of data. (The computer starts counting at 0)

Now, to store information in this array, you simply assign the value to the array just like you would with a variable. Example:

MyArray(0)="First item of data"
MyArray(1)="Second item of data"
MyArray(2)="Third item of data"

etc.

Now, what's really useful about arrays is you can use them with loops to easily extract all the data from it. I don't know if you've studied loops yet, but here's a quick example. Suppose now that you've filled all 30 "slots" of your array with data. Now you can se a "for/next" loop to easily print all that data to the screen.



Now all the information held in that array will be printed to the screen. See how much easier that is than going "print Myvariable1, Print MyVariable 2" etc.

If you can understand all this, then I will continue the lesson with multidimensional arrays. If this is too confusing, lemme know, and I'll try to explain it better.

Cheers and happy coding with DB.

Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 27th Dec 2004 12:16 Edited at: 27th Dec 2004 12:19
Begginers Mistake

[EDIT]
Have a look here;
http://forum.thegamecreators.com/?m=forum_view&t=23785&b=10
[/EDIT]

Jess.


Team EOD :: Programmer/All-Round Nice Guy
Aust. Convention!
comando 300
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 27th Dec 2004 12:21 Edited at: 27th Dec 2004 12:21
http://www.db-tutorials.tk/


CURRENT PROJECT: RETRO PAC-MAN
Iron Maiden
20
Years of Service
User Offline
Joined: 27th Dec 2004
Location:
Posted: 27th Dec 2004 12:43
Ah thank you for making me understand Arrays.

I am no longer stumped because of the help. I appreciate it!

Login to post a reply

Server time is: 2025-05-24 08:39:20
Your offset time is: 2025-05-24 08:39:20