This month we'll explore some of the techniques you can use to debug tasks in the Automate Task Builder. Several features available in Automate 6.1 can help make this an easier process.
The Debug Window section of the Automate Task Builder provides a wealth of information about the task being built. A description of the Debugging Windows (each of which can be "torn off" or undocked for easier viewing):
The Variable window displays all the variables that exist in a task, along with the initial value (the value that the variable is first set to in the Create Variable step), the current value (the value of the variable at the current executing step), and the variable's description. While a task is running, the variables are grey in color until the variable is actually created. The current variable value is updated in the display when a task is paused, stopped, or when a breakpoint is encountered. For more in-depth information, there is an option in the Task Builder Options to update the variable automatically after each step executes, though this sometimes slows performance of the Task Builder. The greatest power of the Variable view is the ability to explore within datasets and arrays by right-clicking on a variable name and choosing "Inspect." In this manner you can see exactly what is inside the array or dataset at runtime.
The Breakpoints Window displays all the breakpoints in the current task. Breakpoints can be set on one or more steps in your task to cause the task to automatically pause when they are encountered. This can allow you to assess the current task state by checking variables, or just to evaluate where the task is at. Once the task is paused at a breakpoint, you can Step through the task (which executes one step at a time each time the Step button is pressed) or continue the task from that point by pressing the Run button again.
The Watches Windows shows all the "watches" set on the task. A watch is an expression that is evaluated after each and every step is executed. Watches go beyond the variable window by providing an excellent means of testing variable or task states while a task is executing. For example, a watch can be set to "myvariable = 10". Once the myvariable variable has a value of 10, the watches window will display "true".
For example, assume we have a task that loops ten times. We have a variable named MyIndex, which we create as the first step in the task, with an initial value of 0. We ad a Loop step, and in-between the Loop and End Loop steps, we add an Increment Variable step (set the variable name to MyIndex) to increase the value of MyIndex by 1 with each loop. Notice in the Variables Window, MyIndex is present, and its initial value is 0. The Current Value is blank since the task has not run yet. To set a breakpoint, click in the grey area to the left of the Increment Variable step. Also, we'll add a watch by selecting the Watches tab, and in the text area, enter %MyIndex = 5%. Notice that the "Value" of this is False for now. Now, run the task. The Variable window will update, and the task will pause at the breakpoint. Click the Step and Run buttons to explore what each does at the breakpoints, and note the values of the Variable Window and Watches Window.