?UNDEF'D STATEMENT ERROR
Commodore VIC-20
Severity: MinorWhat Does This Error Mean?
?UNDEF'D STATEMENT ERROR means a GOTO, GOSUB, or conditional branch references a line number that does not exist in the program. Type LIST to see all existing line numbers, then correct the branch statement.
Affected Models
- Commodore VIC-20
Common Causes
- GOTO or GOSUB references a line number that was never written
- Target line was accidentally deleted
- Line numbers changed but branch statements not updated
- Typo in the line number (e.g. GOTO 1000 when line 100 exists)
How to Fix It
-
Note the line number in the error message.
The VIC-20 reports ?UNDEF'D STATEMENT ERROR IN <line>. That line contains the GOTO or GOSUB with the bad target.
-
Type LIST to see every line in the program.
Scroll through the listing to find whether the target line number exists. If it does not appear, you need to add the missing line or correct the branch.
-
Correct the GOTO or GOSUB to point to an existing line.
Type the line number with the corrected branch. Example: 50 GOTO 200 — if 200 does not exist but 210 does, type: 50 GOTO 210 and press RETURN.
-
Add the missing line if it was accidentally deleted.
If the target subroutine or section was deleted, re-enter those lines. Remember: just typing a line number and pressing RETURN deletes that line on the VIC-20.
Frequently Asked Questions
Why does typing a line number and RETURN delete a line?
In Commodore BASIC V2, a line with content replaces any existing line with the same number. A line number with nothing after it (just pressing RETURN) deletes that line. This is how all Microsoft-derived 8-bit BASICs work.
Is ?UNDEF'D STATEMENT the same as ?UNDEFINED LINE ERROR on other machines?
Yes — different BASIC dialects use different wording for the same concept. Dragon BASIC calls it ?UL ERROR. Sinclair BASIC calls it 'Undefined variable'. The cause is always the same: a branch to a nonexistent line.