contradiction between debug and normal mode

Previous topic - Next topic

Qedo

Hi
this example provides 2 different output in debug mode and in normal mode.
This problem has made me crazy in the vector font program that I'm writing
Ciao
Qedo

// Project: bug
// Start: Tuesday, August 16, 2016
// IDE Version: 14.329

a=0
IF a<>0 THEN
a=a-100
PRINT a , 10,10
SHOWSCREEN
MOUSEWAIT

UBERmonkeybot

do you mean

Code (glbasic) Select

a=0
IF a<>0 THEN a=a-100
PRINT a , 10,10
SHOWSCREEN
MOUSEWAIT



it outputs 0 as i would expect

MrTAToad

#2
To be honest, it shouldn't actually compile at all, as the ENDIF statement is missing.

The difference is because debug mode adds in extra lines on every other line, which release mode does not.

In debug mode, it would look something like :

ON_DEBUG(1)
a=0
ON_DEBUG(2)
if a<>0 then
ON_DEBUG(3)
a=a-100
ON_DEBUG(4)

and so on, making it appear that the code works "correctly"

As mentioned previously you could either use
Code (glbasic) Select
if a<>0 then a=a-100 or

Code (glbasic) Select
if a<>0
a=a-100
endif

dreamerman

Beside that I would always advise to strictly declare your variables, to avoid any strange float to int comparisons.
Check my source code editor for GLBasic - link Update: 20.04.2020

MrTAToad


Qedo

In the example I reported there are two problems:
1) how to properly reported by MrTAToad the program should not compile as the ENDIF statement is missing.
2) Despite compiles in any case, the result is different from release (a = -100) to debug mode (a = 0). Perhaps it is the consequence of point 1

There are not declaration problems or strange float to int comparisons.
In fact, even declaring the variable (GLOBAL a%) the bug (if it exists) remains.

MrTAToad

I suspect the program compiles (when it shouldn't) because the on_debug function is being added to the THEN line.

The reason a is different in the two modes is because of the above.