?OUT OF DATA ERROR
Commodore VIC-20
Severity: MinorWhat Does This Error Mean?
?OUT OF DATA ERROR means your program tried to READ more values than exist in the DATA statements. The READ command has consumed all available DATA items and there are none left. Add more DATA values or use RESTORE to reset the DATA pointer to the beginning.
Affected Models
- Commodore VIC-20
- Commodore VIC-20CR
- VICE emulator (VIC-20)
Common Causes
- More READ statements than DATA values in the program
- A loop READs data without a RESTORE to reset the pointer
- DATA line accidentally deleted or commented out
- Miscounted the number of items in DATA statements
How to Fix It
-
Count the number of READ calls and compare to the number of DATA items.
Every READ consumes one DATA item. If you READ 20 times, you need at least 20 values across all your DATA lines.
-
Use RESTORE before re-reading DATA from the beginning.
RESTORE resets the DATA pointer to the first DATA statement. Useful inside loops: RESTORE before the loop starts each iteration.
-
Check that no DATA lines were accidentally deleted.
Type LIST and look for all lines containing DATA. Make sure none are missing from the sequence.
Frequently Asked Questions
What does RESTORE do on the VIC-20?
RESTORE resets the internal pointer that tracks which DATA item will be READ next. After RESTORE, the next READ starts from the very first DATA value in the program.
Can DATA statements be on any line in the program?
Yes. DATA statements can appear anywhere in the program. BASIC reads them in order from the lowest line number to the highest, regardless of where in the program they appear.