View Full Version : GREAT TIP Global control for DEBUG on / off

08-29-2008, 01:39 AM
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

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


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

Phil Pilgrim (PhiPi)
08-29-2008, 01:53 AM
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.)


Post Edited (Phil Pilgrim (PhiPi)) : 8/28/2008 6:59:47 PM GMT

08-29-2008, 11:37 AM
PhiPi, N -- shouldn't it be

#DEFINE showbugs = 1


#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

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

1uffakind.com/robots/povBitMapBuilder.php (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

08-29-2008, 12:11 PM
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"

to read:

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

The single line·at the head of the program:

#DEFINE Show_Debugs = 1
#DEFINE Show_Debugs = 0

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



Post Edited (Nauketec) : 8/29/2008 5:38:12 AM GMT

Phil Pilgrim (PhiPi)
08-29-2008, 12:12 PM

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


'Sorry for the misdirection! http://forums.parallax.com/images/smilies/blush.gif


08-29-2008, 12:21 PM
No problem

The culture of sharing and learning here is a real comfort


Post Edited (Nauketec) : 8/29/2008 5:39:07 AM GMT