4: BASIC Stamp Architecture – Aliases and Modifiers
A
V
M
LIASES AND
ARIABLE
ODIFIERS
2
2
e
2
2
e
This feature is how the "string" capabilities of the DEBUG and SEROUT
command expect to work. A string is simply a byte array used to store
text.
See the "Displaying Strings (Byte Arrays)" section in the DEBUG
command description for more information.
An alias is an alternative name for an existing variable. For example:
.
1
SYMBOL
Cat
SYMBOL
Tabby
-- OR --
2
2
Cat
VAR
p
sx
Tabby
VAR
In this 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 debugging, you might
end up asking 'how did that value get here?!' The answer is that it was
stored in the variable's alias.
2
2
On the BS2, BS2e, BS2sx and BS2p, an alias can also serve as a window into
p
sx
a portion of another variable. This is done using "modifiers." Here the
alias is assigned with a modifier that specifies what part:
Rhino
VAR
Head
VAR
Tail
VAR
Given that example, if you write the value %1011000011111101 to Rhino,
then Head would contain %10110000 and Tail would contain %11111101.
Table 4.3 lists all the variable modifiers. PBASIC2 lets you apply these
modifiers to any variable name and to combine them in any fashion that
makes sense. For example, it will allow:
Rhino
VAR
Eye
VAR
= B0
= Cat
BYTE
Cat
WORD
Rhino.HIGHBYTE
Rhino.LOWBYTE
WORD
Rhino.HIGHBYTE.LOWNIB.BIT1
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 53
' Create a byte-sized variable.
' Create another name for the same variable.
' Create a byte-sized variable
' Create another name for the same variable.
' A 16-bit variable.
' Highest 8 bits of Rhino.
' Lowest 8 bits of Rhino.
' A 16-bit variable.
' A bit.
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?