ON

PET VIC-20 C64 C16 Plus/4 C128 X16 M65

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|VBLANK GOSUB <label>

For more details, refer to: