GOSUB
GOSUB label
Causes program execution to branch to the specified label; when the RETURN command is encountered, execution branches to the command immediately following the most recent GOSUB command.
GOSUB should be used with caution. Using subroutines is more versatile and much easier to read.
See ON for ON n GOSUB Label1
for branching depending on
a number n
.
Example 1: Using GOSUB
while(ii < 20)
gosub Inc
wend
end ' ends the program
label Inc
ii++print ii
return
Example 2: Same as example 1, but using a subroutine instead of GOSUB
while(ii < 20)
Inc()wend
sub Inc()
ii++print ii
end
Code samples using GOSUB
3d_palmx.bas
3dtictac.bas
3dttt.bas
3dttt.bas
7gables.bas
betrayal: crows ii.bas
bezier_pen.bas
biorythms.bas
blackjack.bas
BlackJack.bas
bolmo.bas
Chaos_1xt.bas
Chaos_NPhase.bas
colors1.bas
crow.bas
cube3d.bas
dataminmax.bas
demanda.bas
dogstar5.bas
esoteric.bas
evdemo.bas
ezinvaders.bas
Fifty50.bas
Fractal_Tree.bas
galgenmann.bas
hangman.bas
illuminati.bas
klotski.bas
klotski.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
If there is insufficient information on this page and you wish learn more about GOSUB,
please send an email to smallbasic@gmail.com. You can help to improve information about
GOSUB by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.