Sinclair ZX Spectrum +2 BASIC Maximum Program Line Length
This article examines the specific technical constraints of Sinclair BASIC as implemented on the Sinclair ZX Spectrum +2 home computer. It focuses on the maximum allowable size for a single line of code within a program listing. Readers will discover the exact byte limit enforced by the system’s read-only memory and understand how tokenization influences this measurement for developers and retro computing enthusiasts.
The Sinclair ZX Spectrum +2, released in 1986, utilized the same foundational BASIC interpreter found in earlier 48K and 128K models. Consequently, the limitations regarding program structure remained consistent across these machines. The maximum length of a program line in Sinclair BASIC is restricted to 255 bytes. This limit applies to the stored line in memory rather than just the visible text on the screen.
When a user types a command, the BASIC interpreter tokenizes keywords. For example, the word “PRINT” is stored as a single byte rather than five individual characters. This tokenization allows programmers to fit more logical commands into the 255-byte limit than would be possible with plain text. However, the line number itself also consumes part of this allocation, along with any variables or strings defined within that specific line.
Exceeding this limit results in a “Line too long” error, preventing the code from being entered or executed. This constraint required developers to write efficient code, often breaking complex operations into multiple numbered lines. Understanding this boundary is essential for anyone studying the architecture of 8-bit home computers or attempting to restore and run original software on the ZX Spectrum +2 hardware.