Debugmode Only Code

BlitzMax Forums/BlitzMax Programming/Debugmode Only Code

Streaksy(Posted 2014) [#1]
Getting in to BlitzMax again. It's great. But I've a question..

I could really use a IfDebugMode(). I need a way to check if debugmode is currently enabled. Even if it checks the runtime filename (how?) for the .debug ...

If you're wondering why, don't worry about it. I know what I'm doing. :P But if you really want to know, its because I run debugmode when troubleshooting - ie expecting an error. And when in fullscreen graphics mode the error dialogue is a hassle to get to. Lots of alt-tab etc. So, when expecting said error, I want it to run windowed. I currently have a fullscreen flag at the top of the code that I set to off when I debug, but it's hassle and I lose my place etc. I've done it a billion times already and it could so easily be automated.

Besides, the debugmode option could be used for your own debugging methods, if only the code could check whether or not it was ticked.

Know what I'm saying? Cheers.


GfK(Posted 2014) [#2]
?debug
'anything here, only happens in Debug mode
?



Grisu(Posted 2014) [#3]
In addition to what GfK posted, you might find "debuglog()" helpful.
?debug
DebugLog ""
DebugLog "I AM DEBUGGING THIS MESSY CODE!"
DebugLog ""
?



Streaksy(Posted 2014) [#4]
Agh it's that simple. Thanks so much, kind harbingers of convenience.


Hardcoal(Posted 2014) [#5]
Good question!
Very helpful Info.
Didn't know that..


GfK(Posted 2014) [#6]
?debug
DebugLog ""
DebugLog "I AM DEBUGGING THIS MESSY CODE!"
DebugLog ""
?
You don't actually need the ?debug tag there, as DebugLog doesn't do anything in Release mode anyway.


Xerra(Posted 2014) [#7]
I've not seen this before either. In anything I write I just use this line at the start:

Global Debug.Byte=True
' Global Debug.Byte=False

and then at various points in the program I would just use:

If Debug=True
' display debugging info on screen
' set screen to windowed mode.
Else
' set screen full screen
End If

Reason being I can just comment out one of the two lines depending on if I want to run in debugging or not.


Derron(Posted 2014) [#8]
Instead of

?debug
do something
?not debug
do something else
?

you can even have:
global debug:int = 0
const DEBUG_NONE:int = 0
const DEBUG_SOUND:int = 1
const DEBUG_GRAPHICS:int = 2
const DEBUG_PHYSICS:int = 4

debug = DEBUG_SOUND | DEBUG_GRAPHICS

if debug then print "some debug mode is enabled"
if debug & DEBUG_SOUND then print "debug sound"
...


bye
Ron