GLBasic forum

G.A.C.K. (gaming app construction kit) => Feedback => Topic started by: Jonás Perusquía on 2012-May-01

Title: IF command bug
Post by: Jonás Perusquía on 2012-May-01
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?
Title: Re: IF command bug
Post by: Moru on 2012-May-01
Code runs fine for me, check higher up in your program so all loops, functions and if/else are terminated.
Title: Re: IF command bug
Post by: Slydog on 2012-May-01
Ya, your problem is most likely above this code.

Also, this line:
Code: (glbasic) [Select]
IF my-10 > y3-1 AND my+71 > y3+60I 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
Title: Re: IF command bug
Post by: Jonás Perusquía on 2012-May-01
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!
Title: Re: IF command bug
Post by: Moru on 2012-May-02
We were right because the same has happened to all of us :-)