5: BASIC Stamp Command Reference – SERIN
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 285
If the serial input were "hello*" DEBUG would display "hello" since it
collects bytes up to (but not including) the end character. It fills the unused
bytes up to the specified length with 0s. DEBUG’s normal STR formatter
understands a 0 to mean end-of-string. However, if you use DEBUG’s
fixed-length string modifier, STR ByteArray\L, you will inadvertently clear
the DEBUG screen. The fixed-length specification forces DEBUG to read
and process the 0s at the end of the string, and 0 is equivalent to DEBUG’s
CLS (clear-screen) instruction! Be alert for the consequences of mixing
fixed- and variable-length string operations.
As shown before, SERIN can compare incoming data with a predefined
sequence of bytes using the WAIT formatter. The simplest form waits for a
sequence of up to six bytes specified as part of the InputData list, like so:
SERIN 1, 16468, [WAIT ("SESAME")] 'Wait for word SESAME.
DEBUG "Password accepted"
SERIN will wait for that word, and the program will not continue until it
is received. Since WAIT is looking for an exact match for a sequence of
bytes, it is case-sensitive—“sesame” or “SESAmE” or any other variation
from “SESAME” would be ignored.
SERIN can also wait for a sequence that matches a string stored in an array
variable with the WAITSTR formatter. 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.
SERIN 1, 16468, [STR SerString\9\"!"] ' Get the string
DEBUG "Waiting for: ", STR SerString, CR
SERIN 1, 16468, [WAITSTR SerString] 'Wait for a match
DEBUG "Password accepted!", CR
You can also use WAITSTR with fixed-length strings as in the following
example:
M
ATCHING A SEQUENCE OF
CHARACTERS WITH
WAIT.
M
ATCHING A SEQUENCE OF
CHARACTERS WITH
WAITSTR.
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
Содержание BASIC Stamp 1
Страница 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...