Shop OBEX P1 Docs P2 Docs Learn Events
Leaving DEBUG in my PBasic Code — Parallax Forums

Leaving DEBUG in my PBasic Code

G McMurryG McMurry Posts: 134
edited 2015-05-11 14:08 in BASIC Stamp
This is something I have always wondered about but never taken the time to ask anyone...

Today I am hammering away at a new piece of PBasic that I need to run as quickly as possible. I am using the BS2SX. During the development process, I use extensive DEBUG commands that slow my program considerably writing all that data to my workstation.

So, here's my question:

If the Editor is not hooked up to the Basic Stamp, do lines of code that call DEBUG routines, take up any time?

I often put a GOSUB command in my main loop to call DEBUG subroutines. If I comment out the GOSUB call, the DEBUG subroutines the debug window to open, even though it doesn't show anything. Is that taking any time away from the rest of my operations?

Greg

Comments

  • SapphireSapphire Posts: 496
    edited 2015-05-10 14:52
    DEBUG takes time if it runs in your program, regardless if the terminal window is open. Commenting out the GOSUB removes them from running, and your program will be faster. But since they are in the code, the editor opens the terminal window not knowing if they will execute or not. They can also take up considerable memory space.

    I use the following around DEBUG statements to quickly remove them
    #DEFINE DIAG = 1
    
    
    #IF DIAG #THEN
    DEBUG DEC ? x
    #ENDIF
    
    

    Set #DEFINE DIAG = 0 to skip the DEBUGs and not open the terminal window.

    You can also get creative and use different values for DIAG to set levels of debugging.
    #IF DIAG = 3 #THEN
    DEBUG "Level 3",CR
    #ENDIF
    
    #IF DIAG > 1 #THEN
    DEBUG "Level 2 or higher",CR
    #ENDIF
    
    
  • G McMurryG McMurry Posts: 134
    edited 2015-05-11 14:08
    Thanks for the great advice...

    Makes sense to me!
Sign In or Register to comment.