Skip to content

BASIC debugger

Commands for the MVsharp BASIC debugger at the terminal, for checking variables, setting breakpoints and stepping through code.

This page covers the debugger you use from an MVsharp terminal session. To debug visually in Visual Studio Code instead, see the MVsharp Debugger extension.

Before you start

A program can only be debugged if it was compiled with the debug option. Without it, you cannot break into the program and all DEBUG statements are ignored.

  1. Compile the program with the D option:

    Terminal
    >BASIC {ProgramFile} {ProgramName} (D
    
  2. Place a DEBUG statement in the program at the point where you want to enter the debugger.

See Compiling BASIC programs for all the compiler options.

Debugger commands

Command Description
? Show the stack trace.
$ Show the program name and line number.
/{var} Display the contents of a variable.
/{var}<x> Display an attribute of a variable.
/{var}<x,y> Display a value of a variable.
/{var}<x,y,z> Display a sub value of a variable.
/@id Display the current session key.
/@record Display the current session record.
B+{line no} Set a break point at the line number.
B-{line no} Remove the break point at the line number.
E{lines} Execute the next lines.
F Display all open file variables.
G Continue execution until the next break point.
I Step into the next subroutine.
P Display the next 10 lines.
P{line no},{lines} Display lines starting from the line number.
Q Quit to TCL.
S Step to the next line.
V Display all variables.

Replace the parts in braces with your own values. For example, /CUST.REC<3> displays attribute 3 of the variable CUST.REC, and B+120 sets a break point at line 120.