Debug Mode in action on a sample script

This topic shows how to debug a sample script.

The script to debug must be first loaded in WinTask Editor. Here is the script :

The script launches notepad, and in a loop types Hello concatenated with the index i. A second index j is there only for the tutorial purpose.

The easiest way to use Debug mode is to put the cursor just before the line where the execution must stop and then watch the variable i. So we put the cursor in front of line 8 and we press F8, keyboard shortcut for Run to cursor (or in the Debug toolbar, we can click the Run to cursor icon or select Debug/Run to cursor menu). The Editor window with the cursor on line 8 looks like :

And after pressing F8, the Editor window is minimized, notepad is launched, Hello1 is typed in notepad, the script stops and the Editor window comes back to focus. Note the green arrow pointing the line where the script stopped (the pointed line is not yet executed).

Before executing line 8, ,we want to know the value of i.

In the Output window (the one in the bottom), we click Watch Tab if it is not on focus, and we click Add new variable :

And in <name>, we type the name of the variable to watch, so i and we press Enter. The value of the variable i is displayed :

Now, let's use a breakpoint. We want to watch the content of the variable j at each iteration, so just before the script executes the line 9 wich contains j=j-1. To insert a breakpoint, we put the cursor in front of line 9 and press F9 (or we click the Breakpoint icon in the Debug toolbar, or we select Debug/Insert breakpoint menu option). The Editor window now looks like :

We continue the script execution by pressing F5 (or we click the Start/Continue debugging icon in the Debug toolbar, or we select Debug/Start/Continue debugging menu option).

The script stops just before executing line 9 :

We want to see the value of the variable j, so we click Add a new variable in the Output window :

And in <name> we write j. The value of j is now displayed, note too that the i variable value has been updated :

We can now loop and at each iteration : on the line where the breakpoint is, the Editor window comes back to focus and in the Output window, we can see the values of variables i and j. So we press F5 to go on with the execution in Debug mode and watch :

 

If you want to stop the execution in Debug mode, press Shift+F5 (or click the Stop debugging icon in the Debug toolbar or select Debug/Stop debugging menu option).

Note that as soon as you close the Editor, all the Debug environment is lost (breakpoints and Watch variables). And the Watch variables list is shared with all the opened scripts within the Editor window.