Your Spectrum
YS MegaBasic manual - Program Debugging & Editing
Home YS MegaBasic Contents

PROGRAM DEBUGGING AND EDITING

BRANCH, TRON, TROFF AND SPEED

The 'BRANCH_' command will come in very useful when you're debugging programs. If, for example, you're interested in a particular variable, you could use a 'BRANCH' subroutine to print its value during the course of program execution.
  Another method of checking program flow is to have the current
16.b

line number printed up on-screen via the command 'TRON'; this displays the current line number in the bottom left-hand corner of the screen. The 'TROFF' command stops the line number from being printed in the corner of the screen.
  Associated with 'TRON' and 'TROFF' is the command 'SPEED_', which requires a single numeric expression to define the speed of the program run. 'SPEED_0' makes the program execute at full speed, whereas any number up to a maximum of 254 makes the execution progressively more slow. If 'SPEED_255' is used then the computer will stop after every statement and wait for the user to press a key.

AUTO AND DELETE

When entering large programs, it's useful if the next line number can be produced every time you press Enter. This can be done by using the command 'AUTO_'. The command requires two numeric expressions separated by a comma, the first is the start line number and the second, the number which is to be added to the line number every time Enter is pressed. To stop auto line numbering, use Extended Symbol Shift 'L'.
  There are many occasions when it's necessary to delete a large block of program lines. This task can be accomplished using the 'DELETE_'command. Like 'AUTO_', 'DELETE_' is followed by two numeric expressions - the first line number of the block to be deleted and that of the last line to be deleted.

BRON AND BROFF

Those wanting to protect their programs from prying eyes will find it useful to be able to disable the Break key. This can be done using the 'BROFF' command - the Break key is re-enabled with 'BRON'. The Break key will still function during input or output operations.
  Many Basics have the 'ON ERROR GOTO' command, allowing users to interrupt error conditions during program flow. The equivalent in YS MegaBasic is 'RESTART_', and it requires a single numeric expression indicating the line to be jumped to when an error occurs. If the 'RESTART_OFF' command is executed the Spectrum will act normally when an error occurs. 'RESTART_' will not trap either Interface 1 or new YS MegaBasic errors. When an error is trapped by the 'RESTART_' command, some useful information is stored in the following locations in memory:
Address 59873/4 The line at which the error occurred.
Address 59875 The statement within the line where the error occurred.
Address 59862 The code of the error that's occurred.
17