BASIC stamp manual v2.2

5: BASIC Stamp Command Reference – DATA
BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com Page 157
To retrieve a word-sized value, you'll need to use the WORD modifier in
the READ command and a word-sized variable.
Finally, a DataItem may be defined using a simple expression with the
binary operators shown in Table 4.5. For example,
MinLvl CON 10
myLvl VAR Byte
Level1 DATA MinLvl + 10
Level2 DATA MinLvl * 5 + 21
READ Level2, myLvl ' read EE location Level2
DEBUG DEC myLvl ' show value of myLvl (71)
Demo Program (DATA.bs2)
' DATA.bs2
' This program stores a number of large text strings into EEPROM with the
' DATA directive and then sends them, one character at a time via the DEBUG
' command. This is a good demonstration of how to save program space by
' storing large amounts of data in EEPROM directly, rather than embedding
' the data into DEBUG commands.
' {$STAMP BS2}
' {$PBASIC 2.5}
idx VAR Word ' current location number
phrase VAR Nib ' current phrase number
char VAR Byte ' character to print
' ----- Define all text phrases (out of order, just for fun!) -----
'
Text1 DATA "Here is the first part of a large chunk of textual "
DATA "data ", CR, "that needs to be transmitted. There's "
DATA "a 5 second delay", CR, "between text paragraphs. ", CR
DATA CR, 0
Text3 DATA "The alternative (having multiple DEBUGs or SEROUTs, "
DATA "each ", CR, "with their own line of text) consumes "
DATA "MUCH more EEPROM ", CR, "(program) space. ", CR
DATA CR, 0
Text6 DATA "The 0 is used by this program to indicate we've "
DATA "reached the ", CR, "End of Text. The Main routine "
DATA "pauses in between each block of", CR, "text,and then "
DATA "uses a LOOKUP command to retrieve the location ", CR
DATA "of the next desired block of text to print. ", 0
All
2
NOTE: This example program can be
used with all BS2 models by changing
the $STAMP directive accordingly.