RSS | Roulette Scripter Studio | Lesson 8 | Using Step over, Trace into, Watches, ...
     
This tutorial was made by Silver
http://www.money-maker-machine.com/forum/profile/Silver/
 
Lesson 8. RSS - secrets (Using Step over, Trace into, Watches, ...).
 
0. Debugging
A major feature of the RSS is the integrated debugger. The debugger enables you to easily set breakpoints, watch variables, and do much more. Using the debugger, you can quickly find out what is happening (or not happening) with your scripts as it runs. A good debugger is vital to efficient script development.

Before getting into the details of the debugger, let's review the menu items that pertain to the debugger.
Item Shortcut Description
Step Over F8 Executes the source code line at the execution point and pauses at the next source code line.
Trace Into F7 Traces into the method at the execution point.
Run to Cursor F4 Runs the script and pauses when script execution reaches the current line in the source code.
Pause Shift+F9 Pauses script execution as soon as the execution point enters the script's source code.
Script Reset Ctrl+F2 Unconditionally terminates the script and returns to the RSS.
Add Watch Ctrl+F5 Displays the Watch Properties dialog box.
Toggle Breakpoint F5 Toggles a breakpoint on or off for the current line in the Code Editor.


I. Using Breakpoints - Toggle Breakpoint
When you run your script, it runs at full speed, stopping only where you have set breakpoints.

New Term: A breakpoint is a marker that tells the debugger to pause script execution when it reaches that place in the script.

Setting and Clearing Breakpoints

To set a breakpoint, click in the editor window's gutter to the left of the line on which you want to pause script execution (the gutter is the gray margin along the Code Editor window's left edge). The breakpoint icon (a red circle) appears in the gutter and the entire line is highlighted in red. To clear the breakpoint, click on the breakpoint icon and the breakpoint is removed. You can also press F5 or choose Toggle Breakpoint from the Code Editor context menu to toggle a breakpoint on or off.

When the script is run under the debugger, it behaves as it normally would--until a breakpoint is hit, that is. When a breakpoint is hit, the RSS is brought to the top and the breakpoint line is highlighted in the source code. If you are using the default colors, the line wh ere the script has stopped is highlighted in red because red indicates a line containing a breakpoint.

New Term: The execution point indicates the line that will be executed next in your source code.

As you step through the script, the execution point is highlighted in blue and the editor window gutter displays a green arrow glyph. Understand that the line highlighted in blue has not yet been executed but will be when script execution resumes.

When you stop at a breakpoint, you can view variables, view the call stack, browse symbols, or step through your code. After you have inspected any variables and objects, you can resume normal script execution by clicking the Run button. Your application will again run normally until the next breakpoint is encountered.

II. Run to Cursor
There is another debugging command that deserves mention here. The Run to Cursor command runs the script until the source line containing the editing cursor is reached. At that point, the script stops as if a breakpoint were placed on that line.

Run to Cursor acts as a temporary breakpoint. You can use this command rather than set a breakpoint on a line that you want to immediately inspect. Just place the cursor on the line you want to break on and choose Run to Cursor (or press F4). The debugger behaves exactly as if you had placed a breakpoint on that line. The benefit is that you don't have to clear the breakpoint after you are done debugging that section of code.

III. Watching Variables - Add Watch
So what do you do when you stop at a breakpoint? Usually you stop at a breakpoint to inspect the value of one or more variables. You might want to ensure that a particular variable has the value you think it should, or you might not have any idea what a variable's value is and simply want to find out.

The function of the Watch List is basic: It enables you to inspect the values of variables. You can add as many variables to the Watch List as you like.

Adding Variables to the Watch List
To add a variable to the watch, choose Debug|Add Watch from the main menu. When the Watch Properties dialog box comes up, enter the name of the variable you want to add to the Watch List and click OK.

Using t he Watch List

When a breakpoint is hit, the Watch List displays the current value of any variables that have been added to the Watch List. If the Watch List isn't currently open, you can choose Debug|View Watches from the main menu to display it.

TIP: Dock the Watch List window to the bottom of the Code Editor window so that it will always be in view when stepping through code.

Under certain circumstances, a message will be displayed next to the variable instead of the variable's value. If, for example, a variable is out of scope or not found, the Watch List displays Undeclared identifier:'X' next to the variable name. If the script isn't running or isn't stopped at a breakpoint, the Watch List displays [process not accessible] for all watch items. Other messages can be displayed depending on the current state of the application or the current state of a particular variable.

IV. Stepping Through Your Code - Step Over and Trace Into

Stepping through code is on e of the most basic debugging operations, yet it still needs to be mentioned here.
When you stop at a breakpoint, you can do many things to determine what is going on with your code. You can set up variables to watch in the Watch List. You can also step through your code to watch what happens to your variables and objects as each code line is executed.

As you continue to step through your code, you will see that the line in your source code to be executed next is highlighted in blue. If you have the Watch List window open, they will be updated as each code line is executed. Any changes to variables or objects will be immediately visible in the watch window. The RSS debugger has two primary stepping commands to aid in your debugging operations: Step Over and Trace Into.

Step Over
Step Over means to execute the next line in the source code and pause on the line immediately following. Step Over is sort of a misnomer. The name indicates that you can step over a source line and the line won't be executed. That isn't the case, however. Step Over means that the current line will be executed and any functions or procedures called by that source line will be run at full speed. For example, let's say you set a breakpoint at a line that calls a function in your script. When you tell the debugger to step over the method, the debugger will execute the function and stop on the next line. (Contrast this with how Trace Into works, which you'll read next, and it will make more sense.) To use Step Over to step through your script, you can either press F8 or choose Debug|Step Over from the main menu.

NOTE: As you step through various source code units in your script, the Code Editor will automatically load and display the needed source units if they are not already open.

Trace Into

The Trace Into command enables you to trace into any functions or procedures that are encountered as you step through your code. Rather than execute the function or procedure and return to the next line as Step Over does, Trace Into places the execution point on the first source code line in the function or procedure being called. You can then step line-by-line through that function or procedure using Step Over or Trace Into as necessary. The keyboard shortcut for Trace Into is F7.

After you have inspected variables and done whatever debugging you need to do, you can again run the script at full speed by clicking the Run button. The script will function normally until the next breakpoint is encountered.

V. Script Pause
Choose Debug|Pause to temporarily pause the execution of a running script.

The debugger pauses script execution and positions the execution point on the next line of code to execute. You can examine the state of your script in this location, then continue debugging by running, stepping, or tracing.

In addition to temporarily pausing a script running in the debugger, you can also stop a script and release it from memory. Use Debug|Script Reset to stop a running script and release it from memory.

VI. Script Reset
Choose Debug|Script Reset to end the current script run and release it from memory.

Use Script Reset to restart a script from the beginning, such as when you step past the location of a bug, or if variables or data structures become corrupted with unwanted values.

When you reset a script, RSS performs the following actions:
- Closes all open script files
- Clears all variable settings

Resetting a script does not delete any breakpoints or watches you have set, which makes it easy to resume a debugging session.
 
Copyright © 2007-2011, All rights reserved to Money Maker Machine