DATA - BASIC Stamp Command Reference
DATA
72, 69, 76, 76, 79
DATA
104, 101, 108, 108, 111
The first DATA directive will start at location 0 and increment the pointer
for each data value it stores (1, 2, 3, 4 and 5). The second DATA directive
will start with the pointer value of 5 and work upward from there. As a
result, the first 10 bytes of EEPROM will look like the following:
0
72
69
Contents
What if you don't want to store values starting at location 0? Fortunately,
the DATA directive has an option to specify the next location to use. You
can specify the next location number (to set the pointer to) by inserting a
DataItem in the form @x ;where x is the location number. The following
code writes the same data in Table 5.4 to locations 100 through 109:
DATA
@100, 72, 69, 76, 76, 79, 104, 101, 108, 108, 111
In this example, the first DataItem is @100. This tells the DATA directive to
store the following DataItem(s) starting at location 100. All the DataItems to
the right of the @100 are stored in their respective locations (100, 101,
102... 109).
In addition, the DATA directive allows you to specify new starting
locations at any time within the DataItem list. If, for example, you wanted
to store 56 at location 100 and 47 at location 150 (while leaving every other
location intact), you could type the following:
DATA
@100, 56, @150, 47
If you have multiple DATA directives in your program, it may be difficult
to remember exactly what locations contain the desired data. For this
reason, the DATA directive can optionally be prefixed with a unique
symbol name. This symbol becomes a constant that is set equal to the
location number of the first byte of data within the directive. For example,
MyNumbers
DATA
This would store the values 72 and 73 starting with location 100 and will
create a constant, called MyNumbers, which is set equal to 100. Your
Page 92 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
EEPROM Location (address)
1
2
3
4
76
76
79
@100, 72, 73
5
6
7
8
104
101
108
108
Table 5.4: Example EEPROM
storage.
9
111
W
RITING DATA TO OTHER LOCATIONS
A
UTOMATIC CONSTANTS FOR DEFINED
.
DATA
.
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?