Ad Space — Top Banner

?OUT OF DATA ERROR

Commodore Commodore 64

Severity: Minor

What 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 and there is nothing left to read. Add more DATA values, use RESTORE to reset the pointer, or fix the READ count.

Affected Models

  • Commodore 64
  • Commodore 64C
  • Commodore 128 (C64 mode)
  • VICE emulator (C64)

Common Causes

  • More READ statements executed than DATA values available
  • Loop READs data repeatedly without RESTORE to reset the pointer
  • DATA line accidentally deleted or has fewer items than expected
  • Mismatched count between READ calls and DATA items

How to Fix It

  1. Count all DATA items and compare to the number of READs.

    Every READ consumes one DATA item from left to right, top to bottom. If you READ 15 times, you need at least 15 values across all DATA lines.

  2. Use RESTORE to reset the DATA pointer to the beginning.

    RESTORE makes the next READ start from the very first DATA item. Use it at the start of loops that re-read the same data.

  3. Check that no DATA lines were accidentally deleted.

    Type LIST and search for all lines containing DATA. Make sure the sequence is complete.

  4. Use a sentinel value to mark the end of data.

    Add -1 (or another impossible value) at the end of your DATA. In the READ loop: READ X : IF X = -1 THEN GOTO (done line). This prevents reading past the end.

Frequently Asked Questions

Can DATA statements be anywhere in the program?

Yes. DATA statements can appear on any line. BASIC reads them in line number order regardless of where they are in the program.

Can I use RESTORE to jump to a specific DATA line?

Not on the C64. RESTORE always resets to the very first DATA item. Some other BASICs support RESTORE (line number), but Commodore BASIC V2 does not.