beautypg.com

Goto, Gosub – Xylem STORM 3 Basic Programming manual User Manual

Page 23

background image

21

Commands and Functions

Jumps to the specified label or line number within the program. GOTO statements never return

back to the point origin and thus have no RETURN statement. Subroutines, defined with the SUB

command, cannot be exited with the GOTO statement.

h = 3

w = 4

d = 5

GOTO 100 REM sets volume to 60

GOSUB ComputeArea REM is never run as above GOTO jumped below

END

LABEL ComputeArea

area = h * w

RETURN

100

volume = h * w * d

GOTO

Branches to the specified LABEL or line number within the program. Once a RETURN statement is

reached, execution is passed back to the statement immediately following GOSUB.

Subroutines, defined with the SUB command, provide a much more flexible method of executing

and running portions of code and should be used instead of GOSUB.


h = 3

w = 4

d = 5

GOSUB 100 REM sets volume to 60

GOSUB ComputeArea REM sets area to 12

END

LABEL ComputeArea

area = h * w

RETURN

100

volume = h * w * d

RETURN

GOSUB