1. Weird error

Maybe it's just me, but I can't understand this error I'm getting:

Subscript value 0 is out of bounds, reading from a length 12 sequence

I'm getting it on this line:

if y1>0 and y1<12 and x>0 then a=barrierow[y1][x+1]

since y1 and x are both >0 I for the read to take place I don't get why
it's crashing with the 0 out of bounds.  Barrierow is an image that's
about 12x150.

Any ideas?

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria

new topic     » topic index » view message » categorize

2. Re: Weird error

>
> Maybe it's just me, but I can't understand this error I'm getting:
>
> Subscript value 0 is out of bounds, reading from a length 12 sequence
>
> I'm getting it on this line:
>
> if y1>0 and y1<12 and x>0 then a=barrierow[y1][x+1]
>
> since y1 and x are both >0 I for the read to take place I don't get why
> it's crashing with the 0 out of bounds.  Barrierow is an image that's
> about 12x150.


What are the actual values of y1 and x?

Thanks

David Gay
http://www.interlog.com/~moggie/Euphoria
"A Beginner's Guide To Euphoria"

new topic     » goto parent     » topic index » view message » categorize

3. Re: Weird error

On Sat, 12 Apr 1997, David Gay wrote:
> >
> > if y1>0 and y1<12 and x>0 then a=barrierow[y1][x+1]
> >
> > since y1 and x are both >0  for the read to take place I don't get why
> > it's crashing with the 0 out of bounds.  Barrierow is an image that's
> > about 12x150.
>
>
> What are the actual values of y1 and x?

um,  0<y1<12 and 150>x>0 just like I stated!  y1 and x are floating point
atoms.  I get it now.  Duh. y1>0 but less than 1 so the indexing rounds
down to 0.  I guess I just had to mail the question to see the answer.

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria

new topic     » goto parent     » topic index » view message » categorize

4. Re: Weird error

> Maybe it's just me, but I can't understand this error I'm getting:
> Subscript value 0 is out of bounds, reading from a length 12 sequence
> I'm getting it on this line:
>
> if y1>0 and y1<12 and x>0 then a=barrierow[y1][x+1]

An interpreted language has to parse up its source code line by line
(this is a simplification, but the idea holds). So when the Euphoria
interpreter gets to this line of your code it begins to parse it up. It
replaces variable names with their values, for example. Before it
executes the line of code Euphoria will look for errors. In this case an
error will happen EVEN THOUGH THAT CODE IS NEVER EXECUTED! There are two
steps, you see? 1) Interpret... 2) Execute.

You don't see this in a compiled language, such as C. That is why it is
faster, becuase it skips the "1) interpret" step.

My suggestion is to split this up into multiple lines, like this.

if y1 > 0 and y1 < 12 then
        a = barrierow[y1][x+1]
endif

new topic     » goto parent     » topic index » view message » categorize

5. Re: Weird error

On Sun, 12 Jan 1997, John DeHope wrote:
> >
> > if y1>0 and y1<12 and x>0 then a=barrierow[y1][x+1]
>
> An interpreted language has to parse up its source code line by line
> (this is a simplification, but the idea holds). So when the Euphoria
> interpreter gets to this line of your code it begins to parse it up. It
> replaces variable names with their values, for example. Before it
> executes the line of code Euphoria will look for errors. In this case an
> error will happen EVEN THOUGH THAT CODE IS NEVER EXECUTED! There are two
> steps, you see? 1) Interpret... 2) Execute.

nope, it doesn't work that way. My error was a rounding thing in the
indexing.  I was scratching my head cuz the code's been working fine for 2
weeks now, and now I'm getting an error.  I use floating point numbers as
indexes frequently (for fractional moves, or for scaling sprites)

Michael Packard
Lord Generic Productions
lgp at exo.com http://exo.com/~lgp
A Crash Course in Game Design and Production
http://exo.com/~lgp/euphoria

new topic     » goto parent     » topic index » view message » categorize

6. Re: Weird error

> > What are the actual values of y1 and x?
>
> um,  0<y1<12 and 150>x>0 just like I stated!  y1 and x are floating point
> atoms.  I get it now.  Duh. y1>0 but less than 1 so the indexing rounds
> down to 0.  I guess I just had to mail the question to see the answer.
>
>
That's why I wanted the ACTUAL values of x and y1, because I had a
suspicion there was a rounding effect, but could not confirm it without
actually knowing your values.

But I am glad you figured it out. :)

David Gay

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu