BASIC stamp manual v2.2

WRITE – BASIC Stamp Command Reference
Page 460 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
The following WRITE command stores the value 245 at location 100:
WRITE 100, 245
--or--
WRITE 100, 245
The EEPROM is organized as a sequential set of byte-sized memory
locations. The WRITE command normally only stores byte-sized values
into EEPROM. This does not mean that you can't write word-sized values,
however. A word consists of two bytes, called a low-byte and a high-byte.
If you wanted to write a word-sized value, you'll need to use two WRITE
commands and a word-sized value or variable. For example,
SYMBOL value = W0
SYMBOL valLo = B0
SYMBOL valHi = b1
value = 1125
WRITE 0, valLo ' write low byte
WRITE 1, valHi ' write high byte
- or -
value VAR Word
value = 1125
WRITE 0, value.LOWBYTE ' write low byte
WRITE 1, value.HIGHBYTE ' write high byte
When this program runs, the two WRITE commands will store the low-
byte and high-byte of the number 1125 into EEPROM.
On all BS2 models, with PBASIC 2.5 you can use a single WRITE
command with the WORD modifier to write a 16-bit value. The low-byte
of the value will be written to Location, the high byte will be written to
Location + 1.
W
RITING WORD VALUES VS. BYTE VALUES.
A
SIMPLE WRITE COMMAND.
1
All
2
1
NOTE: this method is required only if
using PBASIC 2.0. See section below
for PBASIC 2.5 method.
All
2