Unexpected NEXT

Amstrad CPC

Severity: Minor

What it means

Error 1 in Amstrad's list: a NEXT command has been encountered while not in a FOR loop, or the control variable in the NEXT command does not match that in the FOR.

Affected Models

  • Amstrad CPC464
  • CPC664 and CPC6128 (Locomotive BASIC 1.1)

How to Fix It

  1. LIST the program and pair each NEXT with its FOR.

    The inner loop closes first: FOR i ... FOR j ... NEXT j ... NEXT i.

  2. Check the variable after each NEXT against its FOR.