GoTo

GoTo <label> | <line number>

Branches unconditionally out of the normal program sequence to a specified labeled or numbered line

Example of an infinite loop:

Rem Infinite loop

ALabel: GoTo ALabel

Example using line numbers:

10 i%=1

20 Print i% : i%=i%+1

30 If i%>10 Then GoTo 50

40 GoTo 20

50 Print "End"

Example using labels:

i%=1

UpdateCounter:

Print i% : i%=i%+1

If i%>10 Then GoTo ExitLoop

GoTo UpdateCounter

ExitLoop:

Print "End"

Output:

1

2

3

4

5

6

7

8

9

10

End