|
Debug Object / Script Debugging |
|
|
Docklight Scripting offers additional debugging features through the Debug object.
Remarks
The PrintMsg and Assert methods are very useful to print and watch variable values at various points of execution.
For the Debug methods to have any effect, you need to enable Debug Mode first by setting the Mode property to one: Debug.Mode = 1
Example
' Example Debug object
Debug.Mode = 1
Count = 0 Do Count = Count + 1 ' print some debug information: the value of the count variable Debug.PrintMsg "count = " & count ' break script execution when reaching 5 Debug.Assert (Count <> 5) Loop Until Count = 10
' now the same thing with debug mode 'off' - Debug methods have no effect
Debug.Mode = 0 Debug.PrintMsg "this is never printed" Debug.Break ' this is never executed
DL.AddComment "Debug test ended"
After running this script, the communication window could look like this:
07.04.2009 15:45:06.078 line #9 Debug: count = 1
07.04.2009 15:45:06.100 line #9 Debug: count = 2
07.04.2009 15:45:06.119 line #9 Debug: count = 3
07.04.2009 15:45:06.131 line #9 Debug: count = 4
07.04.2009 15:45:06.145 line #9 Debug: count = 5
07.04.2009 15:45:06.158 line #11 Debug: Assert is False (here the user manually continues using the
07.04.2009 15:45:07.781 line #9 Debug: count = 6
07.04.2009 15:45:07.805 line #9 Debug: count = 7
07.04.2009 15:45:07.830 line #9 Debug: count = 8
07.04.2009 15:45:07.853 line #9 Debug: count = 9
07.04.2009 15:45:07.881 line #9 Debug: count = 10 Debug test ended
|