====== Set Debug ======
''Set Debug On|Off''
Set Debug is set to On by default.
You can use this command to control debugging functions in BASIC.
When you don’t need any debugging features, you can use this command to
turn off all Debug commands instead of modifying every instance of of the
Debug command. When this command is used, no Debug command will be
compiled; they are simply discarded from the program.
===== Debug Command How-to =====
When used correctly, the Debug command can help the user identify and fix
bugs in a program. During a program's execution, variables can be
monitored and verified, an LCD can be simulated, and do other tasks can be
performed to increase development productivity.
==== 1. How to Check if program is being reset ====
Sometimes, do to programming errors, a program can be automatically
reset. This condition can be verified using Debug.
Simply put a Debug statement at the beginning of your program, such as
'Debug "=========Reset=========" ' as shown below:
Const Device = CB280
Debug "==========Reset========="
Do
High 0
Delay 200
Low 0
Delay 200
Loop
{{ :cubloc:setdebug:debugreset.png?nolink |}}
If the program is being reset, the "=========Reset=========" line will be
printed more than once.
==== 2. How to check if a particular point of the program is being executed ====
Simply insert a Debug command at the point in question, as shown below:
Const Device = CB280
Do
High 0
Delay 200
Low 0
Delay 200
Loop
Debug "This Part!"
{{ :cubloc:setdebug:debugnoting.png?nolink |}}
The debug statement above will never execute, as the program will execute the Do…Loop indefinitely.
==== 3. How to simulate an LCD ====
You can simulate an LCD using the Debug terminal. Simply use GoXY, XX, YY to access a particular location on the terminal as shown below:
{{ :cubloc:setdebug:debugllikelcd.png?nolink |}}
{{ :cubloc:setdebug:debuglcd.png?nolink |}}
Use the command Debug Clr to clear the debug window.
At any time during development, you can remove all Debug statements from the program's compilation by using the Command Set //Debug Off//.
[[cubloc:index#system_library:|Go CUBLOC home]]