?STRING TOO LONG ERROR
Commodore Retro Computer
Severity: MinorWhat Does This Error Mean?
C64 BASIC strings have a 255-character maximum.
?STRING TOO LONG happens when concatenation or LEFT$/MID$/RIGHT$ produces a result longer than 255.
Split your data into multiple strings (A1$, A2$, A3$) or use a string array.
For very long text, store it in DATA statements and read in chunks.
Affected Models
- Commodore 64
- Commodore 64C
- Commodore 128 in C64 mode
- Commodore VIC-20
Common Causes
- Concatenation pushed length past 255 — A$ = A$ + B$ in a loop
- INPUT or GET concatenated into a single growing string
- MID$ produced a result over 255 characters (rare)
- Reading a long sequential file into one string
How to Fix It
-
Find the offending statement.
Run the program, note the line number printed with the error.
LIST that line and look for + on strings, or INPUT inside a loop. -
Break the string into pieces.
Replace A$ = A$ + B$ with an array: DIM A$(20).
Each element holds up to 255 chars.
Index them as A$(0), A$(1), A$(2). -
Track length before appending.
Add a check: IF LEN(A$)+LEN(B$) > 255 THEN ... do something different.
Either skip, truncate, or move to the next array slot. -
For text editors or long buffers: use multiple variables.
Old C64 word processors got around this by chaining strings — line 1 in L1$, line 2 in L2$, etc.
Or by using the cassette buffer and screen memory directly via PEEK and POKE.
Frequently Asked Questions
Why 255 — couldn't they have made it longer?
C64 BASIC was a tight port of Microsoft BASIC.
String length is stored in a single byte, which maxes out at 255.
Some third-party BASIC extensions (Simon's BASIC, BASIC 7.0 on the C128) have the same limit — it's not really fixable without rewriting the interpreter.