BASIC stamp manual v2.2

RUN – BASIC Stamp Command Reference
Page 384 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
In the BASIC Stamp, the variable RAM is implicitly considered an array.
What this line is doing, then, is moving the value in each RAM address
(B0(1), B0(2), B0(3), ...) to the SPRAM address that corresponds with its
byte index. The process is simply reversed to retrieve the RAM variable
space.
Any ProgramSlot specified above 7 will wrap around and result in running
one of the 8 programs (RUN 8 will run program 0, RUN 9 will run
program 1, etc).
Review the Advanced Compilation Techniques section beginning on page
68 for more information on downloading multiple programs.
Demo Program (RUN1.bsx)
' RUN1.bsx
' This example demonstrates the use of the RUN command. First, the SPRAM
' location that holds the current slot is read using the GET command to
' display the currently running program number. Then a set of values
' (based on the program number) are displayed on the screen. Afterwards,
' program number 1 is run. This program is a BS2sx project consisting of
' RUN1.BSX and RUN2.BSX, but will run on all multi-slot BASIC Stamp models.
' {$STAMP BS2sx, RUN2.BSX}
' {$PBASIC 2.5}
#SELECT $STAMP ' set SPRAM of slot number
#CASE BS2
#ERROR "Multi-slot BASIC Stamp required."
#CASE BS2E, BS2SX
Slot CON 63
#CASE BS2P, BS2PE, BS2PX
Slot CON 127
#ENDSELECT
slotNum VAR Nib ' current slot
idx VAR Nib ' loop counter
value VAR Byte ' value from EEPROM
EEtable DATA 100, 40, 80, 32, 90
DATA 200, 65, 23, 77, 91
Setup:
GET Slot, slotNum ' read current slot
DEBUG "Program #", DEC slotNum, CR ' display
Main:
NOTE: This example program was
written for the BS2sx but can be used
with the BS2e, BS2p, BS2pe, and
BS2px. This program uses conditional
compilation techniques; see Chapter 3
for more information.