BASIC stamp manual v2.2

SERIN - BASIC Stamp Command Reference
Page 404 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
While very effective at filtering and converting input text, the formatters
aren’t completely foolproof. As mentioned before, many conversion
formatters will keep accepting text until the first non-numeric text arrives,
even if the resulting value exceeds the size of the variable. After SERIN, a
byte variable will contain the lowest 8 bits of the value entered and a word
would contain the lowest 16 bits. You can control this to some degree by
using a formatter that specifies the number of digits, such as DEC2, which
would accept values only in the range of 0 to 99.
All BS2 models also have special formatters for handling a string of
characters, a sequence of characters and undesirable characters. See Table
5.101 for a list of these special formatters. Also, see Appendix C for
example serial inputs and the result of using these formatters.
Special Formatter Action
STR ByteArray \L {\E}
Input a character string of length L into an array. If specified,
an end character E causes the string input to end before
reaching length L. Remaining bytes are filled with 0s (zeros).
WAIT (Value)
Wait for a sequence of bytes specified by value. Value can be
numbers separated by commas or quoted text (ex: 65, 66, 67
or “ABC”). The WAIT formatter is limited to a maximum of six
characters.
WAITSTR ByteArray {\L}
Wait for a sequence of bytes matching a string stored in an
array variable, optionally limited to L characters. If the
optional L argument is left off, the end of the array-string must
be marked by a byte containing a zero (0).
SKIP Length Ignore Length bytes of characters.
Table 5.101: SERIN Special
Formatters for all BS2 Models.
There is an additional special formatter for the BS2p, BS2pe, and BS2px,
shown below.
Special Formatter Action
SPSTR L
Input a character string of L bytes (up to 126) into Scratch
Pad RAM, starting at location 0. Use GET to retrieve the
characters.
Table 5.102: Additional SERIN
Special Formatter for the BS2p,
BS2pe, and BS2px.
The string formatter is useful for receiving a string of characters into 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
ONCE AGAIN, PAY ATTENTION TO
POTENTIAL ROLLOVER ERRORS
.
T
HE STR (STRING) FORMATTER.