📖⚡ON GOSUB

Use a lookup table to determine which subroutine to call.

Syntax

ON ByteVariable GOSUB (Label0 , label1..LabelN)

Example

 

' ON..GOSUB EXAMPLE
' OnGosub.txt
' Kic8

DO

  ' Execute each subroutine in turn
  FOR B0 = 0 TO 2 

    ON B0 GOSUB (Sub0, Sub1 , Sub2 )

  NEXT 

LOOP 

Sub0:
  TOGGLE 0
RETURN

Sub1:
  TOGGLE 1
RETURN

Sub2:
  TOGGLE 2
RETURN

todo:

Tutorials: Subroutines

Related Commands: