5: BASIC Stamp Command Reference – SEROUT
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 301
Special Formatter
Action
?
Displays "symbol = x' + carriage return; where x is a number.
Default format is decimal, but may be combined with
conversion formatters (ex: BIN ? x to display "x =
binary_number").
ASC ?
Displays "symbol = 'x'" + carriage return; where x is an ASCII
character.
STR ByteArray {\L}
Send character string from an array. The optional \L
argument can be used to limit the output to L characters,
otherwise, characters will be sent up to the first byte equal to
0 or the end of RAM space is reached.
REP Byte \L
Send a string consisting of Byte repeated L times
(ex: REP "X"\10 sends "XXXXXXXXXX").
The string formatter is useful for transmitting a string of characters from a
byte array variable. A string of characters is a set of characters that are
arranged or accessed in a certain order. The characters "ABC" could be
stored in a string with the "A" first, followed by the "B" and then followed
by the "C." A byte array is a similar concept to a string; it contains data
that is arranged in a certain order. Each of the elements in an array is the
same size. The string "ABC" could be stored in a byte array containing
three bytes (elements). See the “Defining Arrays” section in Chapter 4 for
more information on arrays.
Here is an example that transmits five bytes (from a byte array) through
I/O pin 1 at 9600 bps, N81/inverted:
SerString VAR BYTE(5) ' Make a 5-byte array.
SerString(0) = "H"
SerString(1) = "E"
SerString(2) = "L"
SerString(3) = "L"
SerString(4) = "O"
SEROUT 1, 16468, [ STR SerString\5 ] ' Send 5-byte string.
Note that we use the optional \L argument of STR. If we didn't specify
this, the BASIC Stamp would try to keep sending characters until it found
a byte equal to 0. Since we didn't specify a last byte of 0 in the array, we
chose to tell it explicitly to only send 5 characters.
Parity is a simple error-checking feature. When the SEROUT command's
Baudmode is set for even parity it counts the number of 1s in the outgoing
byte and uses the parity bit to make that number even. For instance, if it is
Table 5.86: BS2, BS2e, BS2sx and
BS2p Special Formatters.
T
HE
STR (
STRING
)
FORMATTER
.
U
SING PARITY AND HANDLING PARITY
ERRORS
.
Summary of Contents for BASIC Stamp 1
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...