WIPIVERSE All articles

TRON command

TRON command (Trace ON) is a debugging statement found in various dialects of the BASIC programming language, most notably Microsoft BASIC implementations such as GW-BASIC, IBM BASICA, QBasic, and QuickBASIC. It instructs the interpreter to display the line number of each statement as it is executed, allowing the programmer to follow the program's flow of control in real-time.

Functionality

When TRON is executed (either in direct mode or within a program), the interpreter enters "trace mode." In this mode, before executing a line of code, the system outputs the current line number enclosed in square brackets (e.g., [10], [20]) to the standard output device (usually the screen). This continues until a TROFF (Trace OFF) command is encountered, the program terminates, or the user breaks execution.

Syntax

TRON

It is typically used without parameters. The complementary command is TROFF, which disables the tracing function.

Use Cases

  • Logic Debugging: Identifying infinite loops, incorrect branching (GOTO, GOSUB, IF...THEN), or unexpected subroutine entry/exit points.
  • Flow Analysis: Verifying the order of execution in complex conditional structures or event-driven routines.
  • Educational Tool: Demonstrating program execution sequence to novice programmers.

Technical Behavior

  • Performance Impact: Execution speed decreases significantly while trace is active due to the I/O overhead of printing line numbers for every statement.
  • Output Format: The standard format is [LineNumber]. In some environments, the output may be directed to a specific file or device if output redirection is supported.
  • Scope: In most implementations, TRON is a global state affecting the entire interpreter session until TROFF is called.

Historical Context

The TRON/TROFF commands were standard features in the BASIC interpreters that shipped with early microcomputers (e.g., Commodore 64 Microsoft BASIC, TRS-80 Level II BASIC, IBM PC BASICA). They represent an early form of interactive debugging available directly within the interpreted environment, predating modern source-level debuggers with breakpoints and variable watches. The commands persist in modern descendants like QB64 and FreeBASIC for backward compatibility.

Browse

More topics to explore

    Browse all articles