NOTE: This is written for the BS2sx and will also run on the BS2e, BS2p, BS2pe, and BS2px. Modify the $STAMP directive (as required) before downloading to the BS2e, BS2p, BS2pe, or BS2px.
' 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: 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
' 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
BASIC Stamp Help Version 2.5.4
Copyright © Parallax Inc.
8/8/2012