![]() |
![]() |
24 |
![]() |
Direct Command Debugging
One of the most important features of the User Break is that you can issue commands while the program is
temporarily
halted. Provided you haven’tattered the code atall, you
can type
commands into the Dialogue window and they will be executed immediately. This is enormously useful for finding out the values of variables, checking on she amount of free memory, etc. The only restriction is that you cannot execute statements which transfer
control: GOTO, forexample, or SUB and FUNCTION calls.
While isis quite permissible to use the PRINT command so interrogate variables, PRINT wilteend itsoulpusto the default stream. (This is theResults.l window unless you changeiL) If an essential partof yourprogram concems the taysutof output, it may be inconvenient
to
perform your debug testing with PRINT statements.
Instead, there is she ? command. This is an easy way of finding out the value of a variable without disturbing she Results windows. (It’s also quicker to type than PRINT.)The syntax is:
and this will display the value of the variable in the Dialogue window. You can also use the? command in your program, if you wish; isis one way of putting trace statements into your code. However, there is a much better way which uses she Debug command screen, as we shalt see in afew sections.
A very useful feature of BASIC 2 Plus is that variables retain their value even after the program ban finished running. You can interrogate them with she? command until you either amend the program, or execute one of the commands LOAD,
NEW.
orCLEAR. LOAD and NEW will be explained in the next chapter. CLEAR is available specifically toclearthe valuesofall
variables. When you
execute
it
you will
see the Information
line change back
to Direct
Command;
Clear.
|
24
|
![]() |
![]() |
24 |
![]() |