Specifications

BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 221
2
‘ Example 2 (null-terminated string):
myText var byte(10) ‘ An array to hold the string.
myText(0) = “H”:myText(1) = “E” ‘ Store “HELLO” in first 5 cells...
myText(2) = “L”:myText(3) = “L”
myText(4) = “0”:myText(5) = 0 ‘ Put null (0) after last character.
debug str myText ‘ Show “HELLO” on the PC screen.
(*Note to experienced programmers: Counted strings normally store
the count value in their 0th cell. This kind of string won’t work with
the STR prefix of Debug and Serout. STR cannot be made to start read-
ing at cell 1; debug str myText(1) causes a syntax error. Since arrays
have a fixed length anyway, it does no real harm to put the count in the
last cell.)
Aliases and Variable Modifiers
An alias variable is an alternative name for an existing variable. For
example:
cat var nib ‘ Assign a 4-bit variable.
tabby var cat ‘ Another name for the same 4 bits.
In that example, tabby is an alias to the variable cat. Anything stored in
cat shows up in tabby and vice versa. Both names refer to the same
physical piece of RAM. This kind of alias can be useful when you want
to reuse a temporary variable in different places in your program, but
also want the variable’s name to reflect its function in each place. Use
caution, because it is easy to forget about the aliases. During debug-
ging, you’ll end up asking ‘how did that value get here?!’ The answer
is that it was stored in the variable’s alias.
An alias can also serve as a window into a portion of another variable.
Here the alias is assigned with a modifier that specifies what part:
rhino var word ‘ A 16-bit variable.
head var rhino.highbyte ‘ Highest 8 bits of rhino.
tail var rhino.lowbyte ‘ Lowest 8 bits of rhino.
Given that example, if you write the value %1011000011111101 to rhino,
then head would contain %10110000 and tail %11111101.