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.

Author
Message
ArcAngel
20
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 23rd Jun 2005 01:07
I'm just not understanding Arrays. For me trying to understand arrays is like solving the "Which came first? The chicken or the egg?" problem. The whole DIM thing is whats really throwing me for a loop. To me it looks like it's just declaring a variable, thats it. In the Programmers Guide to Dark Basic Book it's lesson on arrays is very confusing. For example: DIM BallX(30) is a line in the program. Then it tells you that after you run the program and see what it's results are change the 30 and see what happens. Well nothing happens! Same number of balls, same speed, blah blah blah.
But anyway. If you could just help me understand arrays and DIM I would be very thankful. Peace.

-Strad

"It is well that war is so terrible, or we should grow too fond of it."
"Visit my website! www.freewebs.com/stradigos"
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 23rd Jun 2005 01:17
one way to describe arrays might be to imagine an egg carton with 6x2 spaces

dim eggcarton(6,2)

lets fill the egg carton now with 1's and 0's

for row = 1 to 6
for col = 1 to 2
eggcarton(row,col) = rnd(1)
next row
next col


we didnt use the zero locations in the arrays to make things easier.

dont forget to undim eggcarton(6,2) to flush the data at the end or to recreate the array


this is a very shortwinded introduction to arrays.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
ArcAngel
20
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 23rd Jun 2005 01:19
mmmk... thanks for trying, but i'm still confused.

"It is well that war is so terrible, or we should grow too fond of it."
"Visit my website! www.freewebs.com/stradigos"
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 23rd Jun 2005 01:36 Edited at: 23rd Jun 2005 01:36
This is as simple as it gets, and should help you get your head around it...



BatVink
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 23rd Jun 2005 01:37
get some grid paper and draw a box around 5 x 5 squares

now call that grid say map

dim map(5,5)

now colour in the box at the top left which we can call 1,1

map(1,1) = 1

now colour in map 3,2

map(3,2) = 1

and leave the rest to be blank

this the basis of how arrays work & save time, otherwise you have to express it with many variable names and that can be tiresome and laborious.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
ArcAngel
20
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 23rd Jun 2005 02:23
Holy crap! Wow, I get it now. Talk about a blonde moment. Thanks guys, indi and batvink, if you ever need a favor just holla.

-strad

"It is well that war is so terrible, or we should grow too fond of it."
"Visit my website! www.freewebs.com/stradigos"
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 23rd Jun 2005 11:19
no worries, enjoy coding

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
FakeBlood
21
Years of Service
User Offline
Joined: 18th Nov 2002
Location: Alabama, United States
Posted: 23rd Jun 2005 11:54
Arrays will become your good friend for sure.

Let's say you wanted to create a list of your development team's names with variables and later print them out. With variables...


Now with an array


You can't really notice the time it saves with the arrays there, but imagine if your team had 100 people.


Work In Progress 2D Tile Editor
http://www.geocities.com/charlie2k4/C2D.zip

Login to post a reply

Server time is: 2024-09-23 21:27:21
Your offset time is: 2024-09-23 21:27:21