IF command bug

Previous topic - Next topic

Jonás Perusquía

Hi everyone and Gernot

i was coding a game, when it stopped compiling because an IF didn´t had ENDIF
i searched for the error, but couldn´t find it and couldn´t fix it since the ENDIF was there...

here´s the piece of code where the bug lays:
Code (glbasic) Select
SUB fin3:
IF my-10 > y3-1 AND my+71 > y3+60
CLEARSCREEN RGB(149,0,0)
PRINT "GAME OVER", sx/2-20,sy/2
ENDIF
ENDSUB


Code (glbasic) Select
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.9.829 SN:71fa70a5 - 3D, NET
"TEST2.gbas"(77) error : IF without ENDIF / THEN


i though it was my fault, but now i think this is a bug of GLBasic..

¿What do you think?
<HTML><BASIC><EC>
Be free and do good things

Moru

Code runs fine for me, check higher up in your program so all loops, functions and if/else are terminated.

Slydog

#2
Ya, your problem is most likely above this code.

Also, this line:
Code (glbasic) Select
IF my-10 > y3-1 AND my+71 > y3+60
I didn't even know that was allowed!

I've never done it that way . . . ever.
It is difficult to read and debug.

Doesn't this do the same?:
Code (glbasic) Select
IF my > y3-1+10 AND my > y3+60-71

[Edit] You could also make it clearer by using more descriptive variables or constants for those values, such as (I just made them up as I have no idea what the numbers actually represent):
Code (glbasic) Select
IF player_y > floor_y-1 + floor_thickness AND player_y > floor_y + player_height - jump_height
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Jonás Perusquía

thank you, i found it was my fault :0

i leaved an IF without ENDIF above the code i posted, (you were right!)

thank you for your replies!
<HTML><BASIC><EC>
Be free and do good things

Moru

We were right because the same has happened to all of us :-)