forums

TNT Basic Forums > Programming Q&A
Arrays
< Last Thread     Next Thread >
Author
Thread        Post A Reply

05-16-2004 19:55

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

*** Runtime exception caught ***
Line# : 13
Code : global int num[2]
Error : Array index out of bounds.


I seriously cannot figure out what I did wrong before this.

The only thing declared before this were more variable and graphics mode.

I also have a question about putting arrays inside arrays when declaring setting up variables.

Say I had and array declared as "global int array[10]", and then declared another array as "global int arraytwo[array[10]]"

Does this create the array with ten indexes, or does it create an array with the number of indexes that is the value of 'array[9]' ?

Thanks,
MapMaker

05-16-2004 20:00

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

:/

Now I fiddled around with some of the variables that came after this line, and I got this:


*** Runtime exception caught ***
Line# : 13
Code : global int num[2]
Error : Invalid array dimension.


Help?
MapMaker

05-16-2004 21:14

Posted by:
-wyvern

Location:
Bedroom

Find more posts by -wyvern

hmmm... Try changing the names of variables, or copying and pasting the whole code into a different document. Interpreters can be pretty wierd like that.

05-17-2004 17:43

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

have you tried putting in a comma?

array2[array,[10]] perhaps, or even array2[array[10],[10]]

my starfield code uses something similar to this and is in the directory, although it might be for something completely different

cheers
charlie

05-18-2004 15:15

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

I have learned that a runtime error doesn't necesseraly means the error is at the given line... please post the section of the code that causes the error ( 10-15 lines maybe? )

05-18-2004 21:25

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

array index out of bounds basically means that your trying to use an array index that doesnt exist.

your error message said something like array[2]
to the program this means that there are two indexes in array.
these are numbered 0 and 1, ie array[0] and array[1].
any other number and youll get a runtime error.
if your using a for loop for example, you could write

for p=0 to 1

and this would work, however

for p=0 to 2


wouldnt work because the computer thinks that there are 3 thing in the array.

hope this helps, because from your error message, this seems to be your problem

cheers
charlie

05-19-2004 02:28

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

:/

The same thing happens in a new file.

The array2[array,[10]] wouldn't work because 'array' needed an index.

All of the lines before it and all the line until #25 are just more variable declarations.....

However, I did fin a temporary solution to my problem. I made 'array' a variable instead of an array, and it seems to work fine.

I think its because the declaration for an array (arraytwo[num]), num has to be some form of integer, where in arraytwo[array[2]] no integer is provided, unless it tries to read the data from array[2], which doesn't exist, causing an error.

Thanks for your help,
MapMaker.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.