Specifications
BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 313
2
There are also Waitstr modifiers, which wait for a sequence that
matches a string stored in an array variable. In the example below, we’ll
capture a string with STR then have Waitstr look for an exact match:
serString var byte(10) ' Make a 10-byte array.
serString(9) = 0 ' Put 0 in last byte.
debug "Enter password ending in !",cr
serin 1,16780,[str serString\9\"!"] ' Get the string.
debug "Waiting for: ",str serString,cr
SERIN 1,16780,[WAITSTR serString] ' Wait for a match.
debug "Password accepted.",cr
You can also use WAITSTR with fixed-length strings as in the follow-
ing example:
serString var byte(4) ' Make a 4-byte array.
debug "Enter 4-character password",cr
serin 1,16780,[str serString\4] ' Get a 4-byte string.
debug "Waiting for: ",str serString\4,cr
serin 1,16780,[WAITSTR serString\4] ' Wait for a match.
debug "Password accepted.",cr
Building Compound InputData Statements
Serin’s inputData can be structured as a list of actions to perform on
the incoming data. This allows you to process incoming data in pow-
erful ways. For example, suppose you have a serial stream that con-
tains “pos: xxxx yyyy” (where xxxx and yyyy are 4-digit numbers) and
you want to capture just the decimal y value. The following Serin would
do the trick:
yOffset var word
serin 1,16780,[wait ("pos: "), SKIP 4, dec yOffset]
debug ? yOffset
The items of the inputData list work together to locate the label “pos:”,
skip over the four-byte x data, then convert and capture the decimal y
data. This sequence assumes that the x data is always four digits long;
if its length varies, the following code would be more appropriate:
yOffset var word
serin 1,16780,[wait ("pos: "), dec yOffset, dec yOffset]
debug ? yOffset










