Change of DebugLevel outside procs ...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Change of DebugLevel outside procs ...

Post by helpy »

In the following code the change of the debug level does not have any effect on the Debug calls;

Code: Select all

Macro DebugError( __msg__ )
  Debug "ERROR: " + __msg__
EndMacro

Macro DebugWarning( __msg__ )
  Debug "WARNING: " + __msg__, 1
EndMacro

Macro DebugNote( __msg__ )
  Debug "NOTE: " + __msg__, 2
EndMacro

Procedure SendDebugMessages()
  Debug "-"
  DebugError( "This is an error message ..." )
  DebugWarning( "This is an warning message ..." )
  DebugNote( "This is just a note ..." )
EndProcedure


DebugLevel 0
SendDebugMessages()

DebugLevel 1
SendDebugMessages()

DebugLevel 2
SendDebugMessages()

DebugLevel 3
SendDebugMessages()
Would be nice if this would be implemented
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Re: Change of DebugLevel outside procs ...

Post by Kaeru Gaman »

Syntax
DebugLevel <constant expression>
Description
Set the current debug level for the 'Debug' message.
Note: The debug level is set at compile time, which means than you have to put the DebugLevel command before any other Debug commands to be sure it affects them all.
Syntax
DebugLevel <numerischer Wert>
Beschreibung
Legt den aktuellen DebugLevel für die Debug Mitteilung fest.
Hinweis: Der DebugLevel wird zum Zeitpunkt des Kompilierens festgelegt. Dies bedeutet, dass Sie den DebugLevel Befehl vor jedem anderen Debug-Befehl einfügen müssen, um sicher zu gehen, dass dieser sich auf alle Debug-Befehle auswirkt.
=>
There is only ONE DebugLevel for the WHOLE Debugging session, no change of the Level at Runtime.

you can put ONE DebugLevel instruction to the top of your code, this level will be applied when you press F5 and last until the program ends.
oh... and have a nice day.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: Change of DebugLevel outside procs ...

Post by helpy »

Danke Kaeru! ... Thank you Kaeru ;-)

I did not consider this correlation!

But it is possible to change the DebugLevel during compile time:

Code: Select all

Macro DebugError( __msg__ )
  Debug "ERROR: " + __msg__
EndMacro

Macro DebugWarning( __msg__ )
  Debug "WARNING: " + __msg__, 1
EndMacro

Macro DebugNote( __msg__ )
  Debug "NOTE: " + __msg__, 2
EndMacro

Macro SendDebugMessagesM()
  Debug "-"
  DebugError( "This is an error message ..." )
  DebugWarning( "This is an warning message ..." )
  DebugNote( "This is just a note ..." )
EndMacro

DebugLevel 0
SendDebugMessagesM()

DebugLevel 1
SendDebugMessagesM()

DebugLevel 2
SendDebugMessagesM()

DebugLevel 3
SendDebugMessagesM()
This was the reason for my first request!

Now I know that for each Debug command the DebugLevel is used, which is valid at this point of compilation.

OK! An adminstrator/moderator may move this topic somewhere else.

cu, helpy
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
Post Reply