5: BASIC Stamp Command Reference – SERIN
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 279
communication) to interpret the values as necessary. In this case, perhaps
we actually wanted SerData to end up with the value 1, rather than the
ASCII code 49.
The SERIN command provides a formatter, called the decimal formatter,
which will interpret this for us. Look at the following code:
Symbol SerData = B0
SERIN 1, N2400, #SerData
--or--
SerData VAR BYTE
SERIN 1, 16780, [DEC SerData]
Notice the decimal formatter in the SERIN command. It is the “#” (for the
BS1) or “DEC” (for the other BASIC Stamps) that appears just to the left of
the SerData variable. This tells SERIN to convert incoming text
representing decimal numbers into true-decimal form and store the result
in SerData. If the user running the terminal software pressed the "1", "2"
and then "3" keys followed by a space or other non-numeric text, the value
123 will be stored in SerData. Afterwards, the program can perform any
numeric operation on the number just like with any other number.
Without the decimal formatter, however, you would have been forced to
receive each character (“1”, “2” and “3”) separately, and then would still
have to do some manual conversion to arrive at the number 123 (one
hundred twenty three) before you can do the desired calculations on it.
The decimal formatter is designed to seek out text that represents decimal
numbers. The characters that represent decimal numbers are the
characters “0” through “9”. Once the SERIN command is asked to use the
decimal formatter for a particular variable, it monitors the incoming serial
data, looking for the first decimal character. Once it finds the first decimal
character, it will continue looking for more (accumulating the entire multi-
digit number) until is finds a non-decimal numeric character. Keep in
mind that it will not finish until it finds at least one decimal character
followed by at least one non-decimal character.
D
ECIMAL FORMATTER SPECIFICS
.
1
2
e
2
sx
2
p
2
T
HIS IS WRITTEN WITH THE
BS2'
S
B
AUD
M
ODE VALUE
. B
E SURE TO
ADJUST THE VALUE FOR YOUR
BASIC
S
TAMP
.
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...