BASIC stamp manual v2.2
4: BASIC Stamp Architecture – Aliases and Modifiers
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 89
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 "Displaying Strings (Byte Arrays)" in the DEBUG command
description on page 166 for more information.
An alias is an alternative name for an existing variable. For example:
SYMBOL cat = B0 ' Create a byte-sized variable
SYMBOL tabby = cat ' Create alias for cat
-- or --
cat VAR Byte ' Create a byte-sized variable
tabby VAR cat ' Create alias for cat
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.
On all the BS2 models, an alias can also serve as a window into a portion
of another variable. This is done using "modifiers." Here the alias is
assigned with a modifier that specifies what part to reference:
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 would contain %11111101.
Table 4.3 lists all the variable modifiers. PBASIC 2.0 and 2.5 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 Word ' A 16-bit variable
eye VAR rhino.HIGHBYTE.LOWNIB.BIT1 ' A bit
A
LIASES AND VARIABLE MODIFIERS.
1
All
2
All
2