"IF THEN DEBUG"

Previous topic - Next topic

bigsofty

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.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

bigsofty

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.

Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

MrTAToad

Yes, I had run into that a while ago...  =D

Kitty Hello

dude, that's a nasty one.
I'll fix it in the next update.