Author Topic: contradiction between debug and normal mode  (Read 3126 times)

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 276
  • to program what I have todo how should I program?
    • View Profile
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

Offline UBERmonkeybot

  • Mr. Polyvector
  • ***
  • Posts: 243
    • View Profile
Re: contradiction between debug and normal mode
« Reply #1 on: 2016-Aug-16 »
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

  • Guest
Re: contradiction between debug and normal mode
« Reply #2 on: 2016-Aug-16 »
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
« Last Edit: 2016-Aug-16 by MrTAToad »

Offline dreamerman

  • Global Moderator
  • Dr. Type
  • *******
  • Posts: 366
    • View Profile
    • my personal website
Re: contradiction between debug and normal mode
« Reply #3 on: 2016-Aug-16 »
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

  • Guest
Re: contradiction between debug and normal mode
« Reply #4 on: 2016-Aug-16 »
And indent!

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 276
  • to program what I have todo how should I program?
    • View Profile
Re: contradiction between debug and normal mode
« Reply #5 on: 2016-Aug-17 »
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

  • Guest
Re: contradiction between debug and normal mode
« Reply #6 on: 2016-Aug-17 »
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.