PBTraceState
 

      The PBTraceState constant contains the current state of the compilers trace mode while it's compling your program. This allows you to write code that can ensure parts of your program are compiled with/or without the compiler embedding trace mode hooks into your code.


Trace Modes
      0 = Compiler is NOT embedding Trace Mode codes.
      1 = Compiler is embedding Trace Mode codes.



Mini Tutorial:


      The following example shows how you can ensure that a section of code will be compiled with a specified debugger trace mode enabled, regardless of the current state of trace mode.

      You can use this for your own code/function libraries. This will make sure the PlayBASIC debugger won't trace into your functions for example. This not only makes larger program perform better when compiled in debug mode, it will also make debugging programs much easier too. As the debugger won't trace through code that isn't relevant. (relevant to your debugging that is)

      Of course each section you wish to protect, requires it's own unique constant. This constant stores the debugger trace state prior to the start of this section. It's then used at the end of this sectionto restore the trace mode state.


Note: This code should be compiled/run from the IDE using the F6 (run(trace/debug mode)

  
; displays the state of PB's debug and compile mode constants
  Print pbdebugmode
  
  #IF pbdebug=true
     #IF pbdebugmode=2
        Constant PreviousTraceState=pbtracestate
        #Trace off
     #ENDIF
  #ENDIF
  
; Display the Previous and current trace mode status
  Print "Previous trace state:"+Str$(PreviousTraceState)
  Print "trace mode current status:"+Str$(pbtracestate)
  
  
  
  #IF pbdebug=true
     #IF pbdebugmode=2
        #Trace PreviousTraceState
     #ENDIF
  #ENDIF
  
  
  Sync
  WaitKey
  



When compiled in Debug Mode (F6) this sample will output.

  
  2
  Previous trace state:1
  trace mode current status:0
  




When compiled in normal Mode (F5) this sample will output.

  
  0
  Previous trace state:0
  trace mode current status:0
  




 
Related Info: PBCompileMode | PBDebug | PBDebugMode | PlayBasicVersion :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com