Debug Snippets

Debugging

One of the simplest debugging techniques is done through logging. Snippet facilitates this by offering the TRACE command. This command will execute only within the Studio Snippet debugger. You can access the debugger in the Snippet Properties window; double-click the Snippet action to open this window, click the Text View tab, and the debugger section is on the right-side of the text view. Once a script is deployed and executed on a VC, all TRACE commands will be ignored. The syntax is:

TRACE "<text>"
	

Text within the double-quotes will be output to the Snippet output window below the text view. String substitution is permitted within the double-quotes in order to print the value of variables. Example:

FOR i=1 TO 5
{
   TRACE "I = {i}"
}
	
	Output:
	I = 1
	I = 2
	I = 3
	I = 4
	I = 5
		

Stepping and Breakpoints

A breakpoint can be set within the Snippet editor by clicking in the left gutter on the line of interest. A red sphere will appear in the gutter and the code line will be highlighted in red.

Once a breakpoint is set, the Snippet execution will pause whenever that line is about to be executed. While paused, the current value of all variables will be shown in the debugging window on the right side of the Snippet editor. Two views are available to explore your variables: a text view and a tree view. The text view will not allow expansion of DynamicData variables and custom web service objects, but it will not truncate text and it is possible to use copy/paste features within the window. The tree view allows complex variables to be expanded to drill into their members. Text fields, however, will be truncated at 255 characters to prevent rendering problems with the tree view.

To continue execution after a breakpoint, use either the resume button or the step button in the debugger section. The green arrow will resume execution (until the next breakpoint). The button just to the right is the step button to execute just the next line. The black square is the stop button. It will abort the Snippet execution without delay.

In addition to setting a breakpoint to pause execution, the Snippet can be started in step mode through the left-most dropdown menu button, Step Into. This will start the debugger, but prevent the first line from executing until the Step or Resume button is clicked. This works for most variables with some limitations.