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 / A question about Arrays = Zero? (It's stupid so brace yourselves...)

Author
Message
Wandering Swordsman
20
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 15th Jun 2006 00:33
This is going to sound pretty stupid, but I need to know.

If I create an Array:
DIM ArrayName(#,#,#,#,#)

Will all the coordinates start with a value of 0 by default?

The answer to this could save me a lot of time...
Or doom me to repetitive typing for the next few hours.

When I dream,
I carry a sword in one hand,
a gun in the other...
Wandering Swordsman
20
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 15th Jun 2006 03:14
Ack! I didn't see the 'Newcomers Corner' section of the forum.
I should have posted this there.
*Returns to coding...* it's going to be a long night...

When I dream,
I carry a sword in one hand,
a gun in the other...
Wandering Swordsman
20
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 15th Jun 2006 03:17
!!!

When I said coordinates I don't mean the # in the array I mean
ArrayName(1,2,1,1,2) = ?
Where '?' is the variable I require information on...
(Oops... I'll try to avoid not clarifying in future...)

When I dream,
I carry a sword in one hand,
a gun in the other...
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th Jun 2006 10:09
Everything starts at 0. Repetative typing? You never need to do anything repetative in programming, thats what a loop is for.

Wandering Swordsman
20
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 16th Jun 2006 19:28
Thanks for the help. (That saves me a nice chunk of time!)

Unfortunatly using a loop won't auto-build the database I'm constructing.
(I've got to convert all my design notes into data *sigh* time consuming, but interesting in it's own way...)

Example:
DIM ArrayName(2,2)
ArrayName(0,0) = 0
ArrayName(1,0) = 2
ArrayName(2,0) = 2

ArrayName(0,1) = 18
ArrayName(1,1) = 2
ArrayName(2,1) = 1

ArrayName(0,2) = 17
ArrayName(1,2) = 2
ArrayName(2,2) = 18

I needed a blank array for the program to add values to while it was running, but I still have a lot of data-entry to go for the rest of it.

When I dream,
I carry a sword in one hand,
a gun in the other...
Hobgoblin Lord
20
Years of Service
User Offline
Joined: 29th Oct 2005
Location: Fall River, MA USA
Posted: 22nd Jun 2006 09:53
personally if making an editor to enter the data is not an option i would put those numbers in a text file and read them in in a loop
Slayer93
21
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 22nd Jun 2006 20:29
if u don't want to do that u can use the data command and a for/next loop

Your signature has been erased by a mod because it's larger than 600x120...
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Jun 2006 08:25
an example of what Slayer is saying:



"Using Unix is the computing equivalent of listening only to music by David Cassidy" - Rob Pike
Cash Curtis II
21
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 23rd Jun 2006 10:27
Wandering Swordsman, you don't ever have to use element 0 of an array if you don't want to. I usually just start at position 1. When they're created, they're created with one more element than you specify.

dim a(5) actually creates 6 positions, 0-5. Just start at one and you'll reduce your logic errors. If I use 0 then I use it as a control element. It just depends on what I'm doing.


Come see the WIP!
Wandering Swordsman
20
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 2nd Jul 2006 07:24
@Hobgoblin Lord:
Been working on one for a while...
I'm looking into storing the data in separate files and reading them into the program.

@Slayer93:
Data command is now on my list of things to learn.

@Phaelax:
Thanks for the code snippet.
*Reads it over carefully...*
I see:
By using 'i' & 'j' in the for/next loop and as array coordinates you can transfer the data into the array coordinates as the loops variable changes.

@Cash Curtis II:
Thanks for the info.


*Salutes*
Thanks to everyone who posted to this thread, sorry it took so long for me to post a response.
(This thread has served it's purpose. Now let it slowly fade back into the dark recesses of the DB forum...)

*Returns to coding...*

When I dream,
I carry a sword in one hand,
a gun in the other...

Login to post a reply

Server time is: 2026-07-07 17:31:58
Your offset time is: 2026-07-07 17:31:58