Skip to content
Game 0 Unit 15 of 15 1 hr learning time

When It's Wrong

The C64's error messages are terse, but each one names the problem and points to the line. SYNTAX ERROR, UNDEF'D STATEMENT, ILLEGAL QUANTITY — read them as directions, not scolding, and you can fix anything you write.

100% of Meet C64 BASIC

Every programmer's screen fills with errors — that's the job, not a sign you're bad at it. The C64's messages are blunt: a ?, a couple of words, sometimes a line number. They won't coddle you, but each one names the kind of problem and, inside a program, points to the exact line. Learn to read them and nothing you type can stay broken for long. This unit is a tour of the three you'll meet most.

Milestone 1 — SYNTAX ERROR, the catch-all

Mistype a keyword and the C64 can't understand the line at all:

PRONT "HELLO"
A C64 screen showing PRONT HELLO followed by ?SYNTAX ERROR and READY.
?SYNTAX ERROR is the C64 saying 'I can't read this line.' Almost always a typo — here PRONT for PRINT — a missing quote, or a stray character.

?SYNTAX ERROR is the one you'll see most, and it means exactly one thing: the C64 couldn't make sense of what you typed. Check the spelling of every keyword, that your quotes come in pairs, and that brackets match. Typed at the READY. prompt like this, there's no line number — the mistake is right there on the line above.

Milestone 2 — errors point to the line

Inside a program, an error tells you which line it died on. This one runs, then jumps to a line that isn't there:

10 PRINT "START"
20 GOTO 100

RUN it and the C64 prints START, reaches line 20, and stops:

A C64 screen showing the program, START, then ?UNDEF'D STATEMENT ERROR IN 20 and READY.
?UNDEF'D STATEMENT ERROR IN 20 — line 20 tried to GOTO line 100, which doesn't exist. The 'IN 20' takes you straight to the broken line.

Two gifts in that one message. UNDEF'D STATEMENT means a GOTO or GOSUB aimed at a line number that isn't in the program — a typo'd target, or a line you deleted. And ERROR IN 20 points your finger at the line: type LIST 20 to see just that line and fix it.

Milestone 3 — errors wait until they happen

Some mistakes aren't typos — the line is spelled fine, but it asks for something impossible. The C64 only notices when RUN reaches it:

10 POKE 53281,300

POKE takes values 0255, and 300 is too big:

A C64 screen showing 10 POKE 53281,300, RUN, then ?ILLEGAL QUANTITY ERROR IN 10.
?ILLEGAL QUANTITY ERROR IN 10 — a number out of range. POKE values must be 0–255, and 300 isn't, so the C64 stops at line 10 when it runs.

You met this one back when the screen was memory: ILLEGAL QUANTITY is a number outside what a command allows — a POKE value over 255, a screen cell past the last, a negative where none is allowed. It's a runtime error: the line looked fine when you typed it, and only broke when the program ran into it.

The errors you'll meet

A handful covers almost everything:

MessageWhat it usually means
?SYNTAX ERRORA typo — misspelt keyword, unmatched quote or bracket.
?UNDEF'D STATEMENT ERRORGOTO/GOSUB to a line number that doesn't exist.
?ILLEGAL QUANTITY ERRORA number out of range (e.g. POKE over 255).
?DIVISION BY ZERO ERRORYou divided by zero.
?RETURN WITHOUT GOSUB ERRORA RETURN ran without a matching GOSUB.
?OUT OF MEMORY ERRORThe program is too big, or a loop nested too deep.

When you're stuck

  • Read the line number first. ERROR IN 40 means LIST 40 and stare at that one line.
  • Print to peek. Add a temporary PRINT of a variable just before the broken line to see the value it holds at that moment.
  • Split a busy line. If a line does several things, break it across line numbers so the error points at the exact part.
  • No line number? The error is in what you just typed at the READY. prompt, not in the program.

Before and after

You started treating an error as a dead end and finished reading it as a map: the kind of problem in the words, the place in the line number. The idea underneath: C64 errors are terse directions, not verdictsSYNTAX for "I can't read it", UNDEF'D STATEMENT for a missing line, ILLEGAL QUANTITY for a number out of range, each one pointing you to the fix.

Try this

  • Break it on purpose. Type PRINT 5/0 and meet ?DIVISION BY ZERO. Knowing a message in advance makes it friendly when it turns up for real.
  • Chase a line number. Write a three-line program with a GOTO to a wrong line, run it, and use LIST with the reported number to find and fix it.
  • Catch a range error. POKE 53280, 999 and read what the C64 says — then fix it to a number it accepts.

What's next

That's the whole of BASIC you need: type and run, variables and input, decisions and loops, the screen as memory, colour, sound, the joystick, movement, saving your work, and reading the machine when it complains. You can write C64 programs. From here the primer hands you to the games — real, complete C64 programs you build a piece at a time, starting from the first one. Time to make something.