Parallax BASIC Stamp 2e Programming Manual page 52

Table of Contents

Advertisement

BASIC Stamp Architecture – Defining Variables
See Appendix B for a list of PBASIC keywords. PBASIC does not
distinguish between upper and lower case, so the names MYVARIABLE,
myVariable, and MyVaRiAbLe are all equivalent.
For the BS1, the RegisterName is one of the predefined "fixed" variable
names, such as W0, W1, B0, B1, etc. Here are a few examples of variable
declarations on the BS1:
SYMBOL
Temporary = W0
SYMBOL
Counter
= B1
SYMBOL
Result
= B2
The above example will create a variable called Temporary whose contents
will be stored in the RAM location called W0. Also, the variable Counter
will be located at RAM location B1 and Result at location B2. Temporary is
a word-sized variable (because that's what size W0 is) while the other two
are both byte-sized variables. Throughout the rest of the program, we can
use the names Temporary, Counter, and Result instead of W0, B1 and B2,
respectively.
This makes the code much more readable; it's easier to
determine what Counter is used for than it would be to figure out what the
name B1 means. Please note, that Counter resides at location B1, and B1
happens to be the high byte of W0. This means than changing Counter will
also change Temporary since they overlap. A situation like this usually is a
mistake and results in strange behavior, but is also a powerful feature if
used carefully.
For the BS2, BS2e, BS2sx and BS2p, the Size argument has four choices: 1)
BIT (1 bit), 2) NIB (nibble; 4 bits), 3) BYTE (8 bits), and 4) WORD (16 bits).
Here are some examples of variable declarations on the BS2, BS2e, BS2sx
or BS2p:
Mouse
VAR
BIT
Cat
VAR
NIB
Dog
VAR
BYTE
Rhino
VAR
WORD
Page 50 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
' value can be 0 to 65535
' value can be 0 to 255
' value can be 0 to 255
' Value can be 0 or 1.
' Value can be 0 to 15.
' Value can be 0 to 255.
' Value can be 0 to 65535.
1
1
2
2
2
2
e
p
sx
2
2
2
2
e
sx
p

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?

Table of Contents