Ad Space — Top Banner

?STRING TOO LONG ERROR

Commodore VIC-20

Severity: Minor

What it means

?STRING TOO LONG ERROR means a string variable exceeded 255 characters.
Commodore BASIC V2 has a hard limit of 255 characters per string.
Split long strings into multiple variables or PRINT them in parts.

Affected Models

  • Commodore VIC-20
  • Commodore VIC-20CR
  • VICE emulator (VIC-20)

Common Causes

  • Concatenating strings that together exceed 255 characters
  • Building a string inside a loop that grows beyond 255 characters
  • Trying to store a very long piece of text in a single variable

How to Fix It

  1. Split the string into multiple variables.

    Instead of one 300-character string, use A$ for the first 200 characters and B$ for the rest.
    PRINT A$;B$ displays them together.

  2. PRINT parts of the string directly instead of concatenating first.

    PRINT "Part one ";"Part two " works without creating a combined string.
    This avoids the 255-character limit entirely.

  3. Check loops that build strings — add a length check.

    If A$ grows inside a loop, check LEN(A$) before concatenating more.
    If LEN(A$) > 240, start a new string variable.

Frequently Asked Questions

Why is the limit 255 characters?

Commodore BASIC stores the length of each string in a single byte.
A byte can hold values 0 to 255, so that is the maximum string length.
This is the same limit on the C64 and all Commodore 8-bit computers.

Does this limit apply to string constants in PRINT statements?

String constants in quotes are limited by the maximum line length (80 characters on the VIC-20), not the 255-byte string limit.
The 255 limit applies to string variables in memory.