Snippet Debug Block

Jesus4Lyf

Good Idea™
Reaction score
397
Debug Block

A very simple snippet for having blocks of code in debug mode only, or not in debug mode only.
JASS:
//! textmacro StartDebug
    static if false then
    debug endif
//! endtextmacro
//! textmacro EndDebug
    debug static if false then
    endif
//! endtextmacro
//! textmacro StartNoDebug
    debug static if false then
//! endtextmacro
//! textmacro EndNoDebug
    debug endif
//! endtextmacro


Test script (and example use):
JASS:
scope TestDebugMode initializer OnInit
    private function OnInit takes nothing returns nothing
        //! runtextmacro StartDebug()
            call BJDebugMsg("Debug Mode")
        //! runtextmacro EndDebug()
        //! runtextmacro StartNoDebug()
            call BJDebugMsg("No Debug Mode")
        //! runtextmacro EndNoDebug()
    endfunction
endscope

This abuses static ifs. You can remove functions from your map using this (but defining a function for debug mode and for non-debug mode will count as a multiple declaration still). Does not work for global variable declarations.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Cool trick there. I half-expected you to come out with this.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
how is this diffrent that puting debug infront of the lines you want in debug mode
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
oh but is debug mode like singleplayer only or only when the test map is used?
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
When debug mode is enabled...
Read the JassHelper manual dude. It's awesome.

So this'll let us create blocks of debug-only code? Well that saves a lot of time typing.
 

Artificial

Without Intelligence
Reaction score
326
JASS:
static if DEBUG_MODE then
    // Debug mode is on.
else
    // Debug mode is off.
endif

Works, does it not?

JH Manual said:
You may also use the constant boolean DEBUG_MODE which is set to true or false depending on whether the debug mode is enabled.
JH Changelog said:
0.9.Z.4:
[...]
* You may now use the identifier DEBUG_MODE as a constant boolean that is true if and only if debug mode is on.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Seriously textmacros are ugly, i mean in general using, i would prefer use a static if directly like Artificial showed.
 

Romek

Super Moderator
Reaction score
963
Artificial speaks the truth.

Not only does that look clearer, but it's also shorter to type than a textmacro.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top