GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | ON

Edit History

ON

ON n GOTO|GOSUB label1 [, …, labelN]

Home > Reference > Language

Causes a branch of the program to one of the labels label1 to labelN. n defines the number of the label. If n = 1 the first label is used; with n = N the Nth label is used. n must be in the range 0 to 255.

Example 1: ON … GOTO

n = 1       ' Change to 1,2,3 or other value

ON n GOTO label1, label2, label3

print "Nothing happened"

end

label label1
print "Goto label 1"
end

label label2
print "Goto label 2"
end

label label3
print "Goto label 3"
end

Example 2: ON … GOSUB

n = 1       ' Change to 1,2,3 or other value

ON n GOSUB label1, label2, label3

print "After GOSUB"

end

label label1
print "Gosub label 1"
return

label label2
print "Gosub label 2"
return

label label3
print "Gosub label 3"
return
Code samples using ON
000 hello.bas   001 3 ways to print hello 5 times.bas   002 numeric variables.bas   003 conditional branching.bas   004 loops.bas   005 challenge.bas   006 arrays+.bas   100lines.bas   2048.bas   3d block lettes.bas   3d rotating cube with message.bas   3d wire cube v1.bas   3d wire cube.bas   3d_palmx.bas   3d_torus.bas   3dtictac.bas   3dtorus.bas   3dttt.bas   3dttt.bas   4tune.bas   7gables.bas   agendus.bas   ai.bas   amortig.bas   anball 1.0.bas   angel feather.bas   anomail.bas   Another center finder.bas   another look at trig functions.bas  
Language
AND   AS   BAND   BG   BOR   BYREF   CALL   CASE   CATCH   CONST   DECLARE   DEF   DO   ELIF   ELSE   ELSEIF   END   END TRY   ENDIF   EQV   EXIT   FALSE   FI   FOR   FUNC   GOSUB   GOTO   IF   IFF   IMP   IN   LABEL   LET   LIKE   LOCAL   LSHIFT   MDL   MOD   NAND   NEXT   NOR   NOT   ON   OR   REM   REPEAT   RETURN   RSHIFT   SELECT   STEP   STOP   SUB   THEN   THROW   TO   TRUE   TRY   UNTIL   USE   USG   USING   WEND   WHILE   XNOR   XOR  
This page was last edited on Mon, 19 May 2025 20:22:52 +0930 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.