Docklight Scripting offers additional debugging features through the Debug object.
Method / Property
Debug.Mode = newValue
Sets the script debug mode:
newValue = 0: No Debugging, all Debug methods are ignored.
newValue = 1: Debug Mode. The Debug methods described below are executed.
Breaks the script execution, if assertCondition is False.
The script execution can be continued manually using the Continue Script toolbar.
Breaks the script execution unconditionally.
Adds an additional debug text to the communication window display, including a date/time stamp and the current line of script code.
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 Debug object
Debug.Mode = 1
Count = 0
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 Continue Script button)
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