?UNDEFINED STATEMENT ERROR
Commodore Commodore 64
Severity: MinorWhat Does This Error Mean?
?UNDEFINED STATEMENT ERROR means your program used GOTO, GOSUB, or THEN to jump to a line number that does not exist in the program. Check the target line number in the offending GOTO or GOSUB statement.
Affected Models
- Commodore 64
- Commodore 64C
- Commodore 128 (C64 mode)
- VICE emulator (C64)
Common Causes
- GOTO or GOSUB pointing to a line number that was deleted or never written
- Typo in the line number (e.g. GOTO 1OO with a letter O instead of zero)
- Program edited and a referenced line was removed without updating the GOTO
- RESTORE statement referencing a non-existent line
How to Fix It
-
Type LIST and identify the GOTO or GOSUB line that caused the error.
BASIC reports the line where the jump originated. LIST that area and read the target line number carefully.
-
Check whether the target line number actually exists.
Type LIST followed by the target line number. If nothing appears, that line does not exist in the program — that is the cause.
-
Look for a typo — the letter O versus the digit 0 is a very common mistake.
On the C64 keyboard the letter O and digit 0 look similar. GOTO 1000 is valid; GOTO 1OOO (with letters) will cause UNDEFINED STATEMENT even if line 1000 exists.
-
Add the missing line or correct the GOTO to point to an existing line number.
If the target line was accidentally deleted, add it back. If the line number in the GOTO is simply wrong, retype that line with the correct destination.
Frequently Asked Questions
Is UNDEFINED STATEMENT the same as SYNTAX ERROR?
No. SYNTAX ERROR means the interpreter could not parse a line. UNDEFINED STATEMENT means the line was parsed fine but the jump destination does not exist — it is a runtime error, not a parsing error.
Can I use GOTO with a variable on the C64?
No. Commodore BASIC V2 requires GOTO and GOSUB to specify a literal line number. GOTO X (where X is a variable) is not supported and causes a SYNTAX ERROR.