Specifications

BASIC Stamp II
Page 304 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
Return
RETURN
Return from a subroutine.
Explanation
Return sends the program back to the address (instruction) immedi-
ately following the most recent Gosub. If Return is executed without a
prior Gosub to set the return address, a bug will result. For more thor-
ough coverage of Gosub...Return, see the Gosub writeup.
Demo Program
This program demonstrates how Gosub and Return work, using De-
bug messages to trace the program’s execution. For an illustration of
the bug caused by accidentally wandering into a subroutine, remove
the Stop instruction. Instead of executing once, the program will get
stuck in an infinite loop.
debug "Executing Gosub...",cr
gosub demoSub
debug "Returned."
stop
demoSub:
debug "Executing subroutine.",cr
RETURN