5: BASIC Stamp Command Reference – GOTO
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 133
GOTO
BS1 BS2 BS2e BS2sx BS2p
GOTO
Address
Function
Go to the point in the program specified by Address.
•
Address
is a label that specifies where to go.
Quick Facts
BS1, BS2, BS2e, BS2sx and BS2p
Max. GOTOs
per program
Unlimited, but good programming practices suggest using the least
amount possible.
Explanation
The GOTO command makes the BASIC Stamp execute the code that starts
at the specified Address location. The BASIC Stamp reads PBASIC code
from left to right / top to bottom, just like in the English language. The
GOTO command forces the BASIC Stamp to jump to another section of
code.
A common use for GOTO is to create endless loops; programs that repeat a
group of instructions over and over. For example:
Loop:
DEBUG "Hi", CR
GOTO Loop
The above code will print "Hi" on the screen, over and over again. The
GOTO Loop line simply tells it to go back to the code that begins with the
label Loop.
Demo Program (GOTO.bs2)
' This program is not very practical, but demonstrates the use of GOTO to jump around
' the code. This code jumps between three different routines, each of which print
' something different on the screen. The routines are out of order for this example.
'{$STAMP BS2} 'STAMP directive (specifies a BS2)
GOTO Routine1
Routine2:
DEBUG "We're in routine #2",CR
PAUSE 1000
1
2
e
2
sx
2
p
2
1
2
e
2
sx
2
p
2
NOTE: This is written for the BS2
but can be used for the BS1, BS2e,
BS2sx and BS2p also. Locate the
proper source code file or modify
the STAMP directive before
downloading to the BS1, BS2e,
BS2sx or BS2p.
Table 5.15: GOTO Quick Facts.
Summary of Contents for BASIC Stamp 2e
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...