Runtime Revolution
 
Articles Other News

Cannonballs! Part 3.1


by Robert Cailliau


Watching what goes on

To use the debugging functions of Revolution, we have to switch debugging mode on: select Development-->Script Debug Mode.

Then, in the script window of the Move button, click once in the grey bar on the left, just at the level of the second statement in the handler:

A little red dot appears. That is called a breakpoint. When you make things run in debugging mode, the program will stop at breakpoints.

Now also select Development-->Variable Watcher. A panel pops up that looks like this:

Don't worry about what you see in it, just move it somewhere convenient so that the script of the Move button is still completely visible.

Now run the program and press the Move button. You will see that the statement next to the red dot is now highlighted (note: my highlight colour is yellow, yours may be different):

The program ran until it hit the breakpoint and it is waiting there now. The highlighted statement has not yet been executed. If we now look at the variable watcher, we see:

You may have to drag the horizontal and vertical separation lines to uncover everything.

There are two columns in the upper part, and empty white space in the bottom part. The left column lists all the variables that are used in the handler where the program stopped.

At the bottom of the script window buttons have appeared:

They will allow us to go statement by statement to see what happens. Press the Step Into button once. The highlighted statement executes and the highlight goes down one line. In the variable watcher we now see:

The variable lBallLocation has got the value 40,60. That is the result of executing the statement put the loc of graphic "Ball" into lBallLocation. Press the Step Into button repeatedly, and watch what happens in the variable watcher panel as you do so. Stop when the highlighted statement is the repeat 30 times. We now see:

And that is what we expected. Continue to press the Step Into button, each time observing where the highlighted statement is and what happens in the variable watcher. Also observe the ball move!

When you get bored, press the Run or the Abort button.

As long as you leave the little red dot in the grey margin, the handler of the Move button will stop there.

Remove the breakpoint by clicking it again. The red dot disappears.

 
©2005 Runtime Revolution Ltd, 15-19 York Place, Edinburgh, Scotland, UK, EH1 3EB.
Questions? Email info@runrev.com for answers.