5: BASIC Stamp Command Reference – RETURN
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 265
RETURN
BS1 BS2 BS2e BS2sx BS2p
RETURN
Function
Return from a subroutine, assuming there was a previous GOSUB
executed.
Quick Facts
BS1, BS2, BS2e, BS2sx and BS2p
Maximum
number of
RETURNS per
program
Unlimited. However, the number of GOSUBs are limited. See GOSUB
for more information.
Explanation
RETURN sends the program back to the address (instruction) immediately
following the most recent GOSUB. If RETURN is executed without a prior
GOSUB, the BASIC Stamp will return to the first executable line of the
program; usually resulting in a logical bug in the code. See the GOSUB
command for more information.
The example below will start out by GOSUB'ing to the section of code
beginning with the label Hello. It will print "Hello my friend." on the
screen then RETURN to the line after the GOSUB… which prints "How are
you?" and ENDs.
GOSUB Hello
DEBUG "How are you?"
END
Hello:
DEBUG "Hello my friend.", CR
RETURN
There's another interesting lesson here; what would happen if we removed
the END command from this example? Since the BASIC Stamp reads the
code from left to right / top to bottom (like the English language) once it
had returned to and run the "How are you?" line, it would naturally "fall
into" the Hello routine again. Additionally, at the end of the Hello routine,
it would see the RETURN again (although it didn't GOSUB to that routine
1
2
e
2
sx
2
p
2
W
ATCH OUT FOR SUBROUTINES THAT
YOUR PROGRAM CAN
"
FALL INTO
."
Table 5.68: RETURN Quick Facts.
1
NOTE: On the BS1, a RETURN
without a GOSUB will return the
program to the last GOSUB (or will
end the program if no GOSUB was
executed).
Содержание BASIC Stamp 1
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...