GLBasic forum

Main forum => Bug Reports => Topic started by: bigsofty on 2010-Feb-17

Title: "IF THEN DEBUG"
Post by: bigsofty on 2010-Feb-17
This 'bug' is pretty bad, it affects all GLBasic just now, here is an example from the 3D Entity lib, causing programs ONLY to work properly in debug mode.

Here is an example...

Code: (glbasic) [Select]
FUNCTION EntityLoadTexture: filename$
LOCAL t, sx, sy
t = GENSPRITE()
LOADSPRITE filename$, t
GETSPRITESIZE t, sx, sy
IF sx = 0 THEN DEBUG "failed to load: "+filename$+"\n"
RETURN t
ENDFUNCTION

Now, in debug mode, the above code works fine BUT when not in debug mode the DEBUG command is removed, I guess by the pre-compiler and the next line is used for the THEN statemant.

So I think this is compiled actually compiled...

Code: (glbasic) [Select]
FUNCTION EntityLoadTexture: filename$
LOCAL t, sx, sy
t = GENSPRITE()
LOADSPRITE filename$, t
GETSPRITESIZE t, sx, sy
IF sx = 0 THEN RETURN t // Grabbed from next line
ENDFUNCTION

So in debug mode the code works fine and returns a texture ID, when not in debug mode, it never gets to the "RETURN t" and always returns 0.

Another even simpler example...

Code: (glbasic) [Select]
a=a+1
IF a<100 THEN DEBUG "asddasdasd"
PRINT "I'm here!", 0,20

Try these lines with DEBUG on and then with DEBUG off, with off, the PRINT will die in non-debug mode.
Title: Re: "IF THEN DEBUG"
Post by: bigsofty on 2010-Feb-17
I know how to avoid the bug, I have posted about it in the past but its catching other people out, none the less. I personally use the preprocessor to avoid this kind of thing altogether.

At its simplest, it really should not happen, one line merging into another just because you turned off the debugger, this in essence is what should be fixed.

Title: Re: "IF THEN DEBUG"
Post by: MrTAToad on 2010-Feb-17
Yes, I had run into that a while ago...  =D
Title: Re: "IF THEN DEBUG"
Post by: Kitty Hello on 2010-Feb-18
dude, that's a nasty one.
I'll fix it in the next update.