Specifications
BASIC Stamp II
Page 322 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
modifiers that Serout understands. You can try these modifiers using
Debug (which is actually just a special case of Serout configured spe-
cifically to send data to the STAMP2 host program).
Literal Text and Compound OutputData
Serout sends quoted text exactly as it appears in the outputData list:
Serout 1,16468,["A"] ' Send byte value 65 ("A").
Serout 1,16468,["HELLO"] ' Send series of bytes, "HELLO".
Since outputData is a list, you may combine modifiers, values, text,
strings and so on separated by commas:
temp var byte
temp = 96
Serout 1,16468,["Temperature is ", dec value, " degrees F."]
Serout would send "Temperature is 96 degrees F."
Sending Variable Strings
A string is a byte array used to store variable-length text. Because the
number of bytes can vary, strings require either an end-of-string marker
(usually the ASCII null character—a byte with all bits cleared to 0) or a
variable representing the string’s length. PBASIC2 modifiers for Serout
supports both kinds of strings. Here’s an example of a null-terminated
string:
myText var byte(10) ' An array to hold the string.
myText(0) = "H":myText(1) = "E" ' Store "HELLO" in 1st 5 cells...
myText(2) = "L":myText(3) = "L"
myText(4) = "0":myText(5) = 0 ' Put null (0) after last character.
Serout 1,16468,[STR myText] ' Send "HELLO"
The other type of string—called a counted string—requires a variable
to hold the string length. In most other BASICs, the 0th element of the
byte array contains this value. Because PBASIC2 outputs the 0th array
element, this is not the best way. It makes more sense to put the count
in a separate variable, or in the last element of the array, as in this
example:










