BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – RUN
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 385
FOR idx = 0 TO 4 ' read/display table values
READ (slotNum * 5) + idx, value
DEBUG DEC3 value, " "
NEXT
DEBUG CR
PAUSE 1000
RUN 1 ' run Slot 1 pgm
Demo Program (RUN2.bsx)
' RUN2.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 0 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}
' {$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:
FOR idx = 0 TO 4 ' read/display table values
READ (slotNum * 5) + idx, value
DEBUG DEC3 value, " "
NEXT
DEBUG CR
PAUSE 1000
RUN 0 ' back to Slot 0 pgm
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.