Parallax BASIC Stamp 2e Programming Manual page 281

Table of Contents

Advertisement

2
2
e
T
BS2'
HIS IS WRITTEN WITH THE
B
M
. B
AUD
ODE VALUE
E SURE TO
ADJUST THE VALUE FOR YOUR
S
.
TAMP
D
ECIMAL FORMATTER SPECIFICS
5: BASIC Stamp Command Reference – SERIN
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:
1
Symbol
SerData
SERIN 1, N2400, #SerData
--or--
2
2
SerData
VAR
p
sx
SERIN 1, 16780, [DEC SerData]
S
Notice the decimal formatter in the SERIN command. It is the "#" (for the
BASIC
BS1) or "DEC" (for the other BASIC Stamps) that appears just to the left of
the SerData variable.
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.
= B0
BYTE
This tells SERIN to convert incoming text
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 279

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?

Table of Contents