Ad Space — Top Banner

Data exhausted

Amstrad Retro Computer

Severity: Minor

What Does This Error Mean?

'Data exhausted' in Locomotive BASIC means a READ statement asked for another value but there was no more DATA to read.
Either the loop ran longer than your DATA list, or you missed a DATA statement, or RESTORE wasn't called when needed.
Count the items in your DATA, count what your loop asks for, then either trim the loop or add more DATA.

Affected Models

  • Amstrad CPC 464
  • Amstrad CPC 664
  • Amstrad CPC 6128
  • Amstrad CPC 464 Plus
  • Amstrad CPC 6128 Plus

Common Causes

  • Loop reads more values than DATA contains
  • Forgot to write all DATA lines
  • RESTORE not used to reset the read pointer
  • READ in a subroutine called more times than expected

How to Fix It

  1. Count DATA values.

    List the program with LIST.
    Find every DATA line.
    Count the comma-separated values on each.
    Sum them — that's your total.

  2. Count what READ asks for.

    FOR I=1 TO 20: READ A: NEXT reads 20 values.
    If your DATA total is only 15, you're 5 short.
    Either add 5 DATA values or shorten the loop to 15.

  3. Use RESTORE if you want to read again.

    RESTORE resets the read pointer to the first DATA.
    After RESTORE you can READ from the beginning again.
    RESTORE 100 jumps the pointer to the DATA at line 100.

  4. Add a sentinel value.

    Many programs end DATA with a marker — like -1 or "END".
    Then READ in a WHILE loop and stop when sentinel is seen.
    This avoids miscounting entirely.

Frequently Asked Questions

Does Data exhausted ever mean the DATA is corrupted?

On the Amstrad it specifically means the read pointer reached the end with nothing left to read.
Bad data values usually trigger Type Mismatch instead.
If you see Data exhausted but you think there's plenty of DATA, check that your DATA lines are spelled correctly — DATA misspelled won't be recognised.