Shop OBEX P1 Docs P2 Docs Learn Events
GREAT TIP Global control for DEBUG on / off — Parallax Forums

GREAT TIP Global control for DEBUG on / off

NauketecNauketec Posts: 51
edited 2008-08-29 05:21 in BASIC Stamp
I have searched through the manuals and have not found a way to turn all DEBUGs on or off with one· = 1, ·or =0

one example is:

#IF Show_Debugs = 1· #THEN
DEBUG·· 2,0,4, "P0 - P3 ", BIN3 SelectMode
#ENDIF

I have been trying to change:
Show_Debugs = 1··
for Show_Debugs = OnOff

Then set· OnOff to 1 or 0 to have all the debug windows display or not.

It keeps saying that it is illegal or ....

Any Ideas

Daniel

Post Edited (Nauketec) : 8/29/2008 5:19:04 AM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-08-28 18:53
    Your idea is sound. You just need to define Show_Debugs and OnOff as CONstants, viz:

    OnOff       CON 1
    Show_Debugs CON OnOff
    
    
    


    (It's probably simpler just to define Show_Debugs as 0 or 1, though, and skip the OnOff bit.)

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 8/28/2008 6:59:47 PM GMT
  • ZootZoot Posts: 2,227
    edited 2008-08-29 04:37
    PhiPi, N -- shouldn't it be

    #DEFINE showbugs = 1

    or

    #DEFINE showbugs = 0

    "Define" is for setting constants that are only to be used with conditional #IF #THEN compilation statements.

    See the Pbasic Manual·-- Advanced Compilation Techniques, and look for·conditional compilation. In my version of the manual it's on page 68.

    Or do you want your flag (onoff) to be a VARIABLE that you can change at run-time (with a switch input or whatever) then you use regular if thens:

    debugOnOff VAR bit (or a PIN input if you want to literally switch debugging on and off)
    On CON 1
    Off CON 0

    IF debugOn = On THEN
    ·· DEBUG "Hello world.", CLREOL
    ENDIF

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • NauketecNauketec Posts: 51
    edited 2008-08-29 05:11
    Howdy All,

    It seems by leaving out the = 0 or = 1 part in the

    #IF Show_Debugs = 1 #THEN
    'DEBUG 2,0,3, "any debug statement here"
    #ENDIF

    to read:

    #IF Show_Debugs #THEN
    'DEBUG 2,0,3, "any debug statement here"
    #ENDIF


    The single line·at the head of the program:

    #DEFINE Show_Debugs = 1
    or
    #DEFINE Show_Debugs = 0

    Will do the trick to turn all the DEBUG comments on or off

    Thanks

    Daniel

    Post Edited (Nauketec) : 8/29/2008 5:38:12 AM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-08-29 05:12
    Zoot,

    Yup, you're right, of course: #DEFINE it is.

    Nauketec,

    'Sorry for the misdirection! blush.gif

    -Phil
  • NauketecNauketec Posts: 51
    edited 2008-08-29 05:21
    No problem

    The culture of sharing and learning here is a real comfort

    Daniel

    Post Edited (Nauketec) : 8/29/2008 5:39:07 AM GMT
Sign In or Register to comment.