BASIC

Author Topic: IF command bug  (Read 1774 times)

Offline Jonás Perusquía

  • Mr. Polyvector
  • ***
  • Posts: 170
    • View Profile
    • Ditrabox
IF command bug
« 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?
« Last Edit: 2012-May-01 by jonaspm »
<HTML><BASIC><EC>
Be free and do good things

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1749
    • View Profile
    • Homepage
Re: IF command bug
« Reply #1 on: 2012-May-01 »
Code runs fine for me, check higher up in your program so all loops, functions and if/else are terminated.

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 924
  • KodeSource
    • View Profile
    • KodeSource
Re: IF command bug
« Reply #2 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+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
« Last Edit: 2012-May-01 by Slydog »
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline Jonás Perusquía

  • Mr. Polyvector
  • ***
  • Posts: 170
    • View Profile
    • Ditrabox
Re: IF command bug
« Reply #3 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!
<HTML><BASIC><EC>
Be free and do good things

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1749
    • View Profile
    • Homepage
Re: IF command bug
« Reply #4 on: 2012-May-02 »
We were right because the same has happened to all of us :-)