ON

The ON … GOTO|GOSUB construct has multiple use cases:

  • ON <value> GOTO|GOSUB is used for multiple branching
  • ON ERROR GOTO is used for error trapping
  • ON <event> GOSUB is used for interrupt handling

Syntax

ON <value> GOTO|GOSUB <label> [, <label> ...]
ON ERROR GOTO <label>
ON TIMER|RASTER|SPRITE|BACKGROUND GOSUB <label>

For more details, refer to: