4: BASIC Stamp Architecture – Aliases and Modifiers
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 53
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:
SYMBOL Cat = B0 ' Create a byte-sized variable.
SYMBOL Tabby = Cat ' Create another name for the same variable.
-- OR --
Cat VAR BYTE ' Create a byte-sized variable
Tabby VAR Cat ' Create another name for the same variable.
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 the BS2, BS2e, BS2sx and BS2p, 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:
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. 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 WORD ' A 16-bit variable.
Eye VAR Rhino.HIGHBYTE.LOWNIB.BIT1 ' A bit.
1
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
A
LIASES AND
V
ARIABLE
M
ODIFIERS
.
Summary of Contents for BASIC Stamp 1
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...