Fast Track 4

From BR Wiki
Jump to navigation Jump to search

DEBUGGING

BR allows you to make changes to programs while they are running, which makes debugging considerably simpler.

LIST and it's forms mentioned earlier can help in the debugging process to show where variables are used. Another option, LIST 'DIM' 'SomeVariable' will display all the lines that contain both words, 'dim' and 'somevariable' (case insensitive). This is useful for finding out what a variable is dimmed to (How big a string it can hold, or how many elements an array has).

Pause

Placing a PAUSE statement in the program just before where you think a problem might be allows you to test the values of variables and test what is going wrong by entering Step Mode.

Go Step

GO STEP will make the program run step by step, giving you a chance to test variable values and other indicators of how the program is functioning, in order to solve problems. You can see the current line at the bottom of the screen and you press ENTER to continue forward through the program a line at a time. You'll be able to tell if the program jumps to an unexpected line or does anything else peculiar.

Status

The Status command has several options that list various information that is useful for debugging. More info can be found on the wiki page: Status

Here are the most useful options:

Status Stacks (st st) shows the status of BRs memory stacks. This is useful for debugging errors 9001 - 9004.

Below that it lists the current line, and the complete path through the program of any gosubs or function calls that caused you to get to the current line. This is useful for debugging programs where the error is in a function and you need to see what line called the function. Its also useful for debugging ScreenIO programs when you want to know how many screens deep you're in.

Status Files (st fi) lists all open files, their keys, record lengths, key positions, and key lengths. It's useful for debugging key length conflicts and knowing what file a read statement pertains to without searching the code.

Status Config (st con) lists the currently active config statements, including all OPTION codes and their meanings. This is useful for debugging config related issues, (for example if you change the brconfig.sys and it doesn't seem to be working, you can check here to see if it was read or not) and seeing which attribute substitution statements and printer substitution statements are in effect. Its also useful for seeing the full list of backwards compatibility OPTION statements that BR supports and their meanings, and which ones you have enabled or disabled.

Status Dim (st dim) lists all the variables in use in your program, which could be really useful, particularly for debugging issues such as String Overflow (error 58) and debugging issues relating to arrays and invalid array elements (error 122). It would also be a good place to check for misspelled variable names.

Status ENV (St env) lists all the system and br environment variables that are currently set. This is useful if the ENV$ function is returning something you don't expect.

Others

Other internal functions can be useful for debugging, including UDIM for checking the size of a MATrix.


NEXT:Intermediate Tutorial