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 / Array accessed out of bounds :?

Author
Message
Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 28th Sep 2005 20:37
This is my first time experimenting with the DIM vars....after reading the begginers guide to darbasic...this is the code so far...



Dark
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Sep 2005 21:05
DIM way(max) = 0
sh = 0
max = 15


Should be...

max = 15
DIM way(max)

At the point you use the variable Max in the DIM, it doesn't exist. Also, you don't put = 0 on the end.

TDK_Man

blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 28th Sep 2005 22:51
Indeed, listen to teh TDK.

What's happening at the moment, is when a variable hasn't been initialized yet it is 0; So until it executes the line 'max=15', max (and every other variable) will by default be 0 until changed.

So as far as the compiler is concerned, it runs the command:
DIM way(0)

(Arrays in DB start from 0 and go up to the number in brackets in the DIM statement.)

So whenever you try to access an entry that isn't 0, the array has been accessed out of its bounds.

(TDK posted the fix, btw.)

Part of the 'Emergency Response Noob Shooting Team' :: Feel free to add me to MSN, but don't expect any big favours.
I AM _NOT_ A MOD, I AM ONLY HUMAN (although I fly in my spare time).
Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 29th Sep 2005 02:39
thank you very much TDK, and blanky!

Dark

Login to post a reply

Server time is: 2025-05-22 12:51:05
Your offset time is: 2025-05-22 12:51:05