Debug Object / Script Debugging

<< Click to Display Table of Contents >>

Navigation:  Reference (Scripting) >

Debug Object / Script Debugging

Docklight Scripting offers additional debugging features through the Debug object.

 

Method / Property

Description

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.

Debug.Assert assertCondition

Breaks the script execution, if assertCondition is False.

The script execution can be continued manually using the Startscript_new Continue Script toolbar.

Debug.Break

Breaks the script execution unconditionally.

Debug.PrintMsg debugMsg

Adds an additional debug text to the communication window display, including a date/time stamp and the current line of script code.

 

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 Startscript_new 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