PDA

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



Nauketec
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
#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

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.)

-Phil

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

Zoot
08-29-2008, 11:37 AM
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 (http://1uffakind.com/robots/povBitMapBuilder.php)
1uffakind.com/robots/resistorLadder.php (http://1uffakind.com/robots/resistorLadder.php)

Nauketec
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"
#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)
08-29-2008, 12:12 PM
Zoot,

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

Nauketec,

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

-Phil

Nauketec
08-29-2008, 12:21 PM
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