User Tools

Site Tools


pausing_20under_20program_20control

Pausing under program control

by Richard Russell, February 2007

When running a program from the Interactive Development Environment you can enter (or exit) paused mode using the menu selection Run… Pause, clicking the Pause button on the toolbar or pressing the F8 key (if the IDE window has the input focus).

It is also possible to enter and exit paused mode automatically using statements within your own BASIC program. To enter paused mode execute the following code:

        TRACE STEP ON

As soon as this statement is executed the program will pause and can be single-stepped in the usual way (via a menu selection, the Step button in the toolbar or pressing F7). You will normally want to select the Trace and/or List Variables utility to display useful information while stepping.

To exit paused mode and resume normal execution use the following code:

        TRACE STEP OFF

You may wish to write your own PROCpause and PROCunpause procedures which execute these statements conditionally depending on some detected state. For example to pause only when the program is running under the IDE you can do:

        DEF PROCpause
        LOCAL cmd%
        SYS "GetCommandLine" TO cmd%
        IF INSTR($$cmd%, "bbcwin.exe") TRACE STEP ON
        ENDPROC

If you have a particularly difficult bug to trace you could arrange to pause your program only when a specific condition is met, such as a variable having a certain value or a particular key being pressed.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
pausing_20under_20program_20control.txt · Last modified: 2018/04/17 18:11 by tbest3112