Home
Free Midlets
Help

GOTO

Syntax: GOTO lno | variable | expression

Causes execution to proceed with the line number specified by "lno".

10 PRINT 1
20 GOTO 40
30 PRINT 2
40 PRINT 3

The above program prints 1 and 3. It does not print 2 because line 30 never gets executed. The GOTO statement at line 20 causes control to pass directly to line 40.

You can also use a variable to specify a line number as the following example illustrates.

10 FOR I%=30 TO 50 STEP 10
20 GOTO I%
30 PRINT "Line Thirty"
35 GOTO 60
40 PRINT "Line Forty"
45 GOTO 60
50 PRINT "Line Fifty"
60 NEXT I%