[gameprogrammer] Re: subscript out of range?
- From: "Chris Schnurr" <chris.schnurr@xxxxxxxxxx>
- To: <gameprogrammer@xxxxxxxxxxxxx>
- Date: Mon, 31 Jan 2005 16:21:25 -0000
Hi!
Check your code. VB is a little inconsistent with its array use:-
dim MyArray(10) as string
actually gives you an 11 item array, items 0 -> 11.
Sometimes VB starts at zero, sometimes it starts at 1. Have you tried
stepping through the code? VB has quite a good Debugging tool that allows
you to visually see what its doing step by step. I'd be happy to help you
out on VB usage if you are still stuck.
[sarcasm]
note to everyone else: Let's start a flame war on why not to use VB in game
programming.
[/sarcasm]
:)
regards,
C
-----Original Message-----
From: gameprogrammer-bounce@xxxxxxxxxxxxx
[mailto:gameprogrammer-bounce@xxxxxxxxxxxxx]On Behalf Of Daniel Greeson
Sent: 31 January 2005 16:09
To: gameprogrammer@xxxxxxxxxxxxx
Subject: [gameprogrammer] Re: subscript out of range?
I am programming in VB I can check my declarations that might be the problem
because I did add the new declaration along with the new procedure, but if
you could think of any more information it is still greatly appreciated.
Bob Pendleton <bob@xxxxxxxxxxxxx> wrote:On Mon, 2005-01-31 at 05:56 -0800,
Daniel Greeson wrote:
> Hey everyone I hope everyone is doing well.
>
> I am having a problem I keep getting a subscript out of range error. I
just added a graphics portion to my source code and this error is popping up
I was wondering if anyone could give me some information about this error.
thanks in advance,
>
> ~Draven~
>
Which language are you using? We need to know that to give you specific
information. In general it means that your program is trying to access a
part of a vector or array that does not exist. For example, in C you
might have the declaration:
int iv[10];
Which gives you a vector of 10 integers. The valid subscripts for that
vector are from 0 to 9 inclusive. If I had an expression that included
iv[10] or iv[-1] I would have an out of range subscript error. Now, you
most likely aren't using C because C doesn't normally check for
subscript errors. But, you get the idea.
The most common reason for getting a subscript error is a loop that goes
past the end of a vector. For example:
int i;
int iv[10];
for (i = 0; i <= 10; i++) {
printf("iv[%d] = %d\n", i, iv[i]);
}
Note that the test "i <= 10" will set to to values in the range 0 to 10
and 10 is an invalid subscript of the vector iv.
The error is most likely in your code. But, if you are passing out of
range values to a library function you could be triggering the error in
a library.
Bob Pendleton
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Search presents - Jib Jab's 'Second Term'
>
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
---------------------------------
Do you Yahoo!?
Yahoo! Search presents - Jib Jab's 'Second Term'
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] Re: subscript out of range?
- From: Daniel Greeson
Other related posts:
- » [gameprogrammer] subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- [gameprogrammer] Re: subscript out of range?
- From: Daniel Greeson