EasyManua.ls Logo

Parallax BASIC Stamp II - Defining Constants (CON)

Default Icon
68 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Page 20 • BASIC Stamp II Manual 0.94 • Parallax, Inc. • (916) 624-8333
BASIC Stamp II
symbol VAR variable.modifiers
- symbol is a unique name for a variable
- variable is a defined variable name
- .modifiers are optional and used to define variables-within-variables
The compiler will group all declarations by size (in the case of unique
variables) and assign them to unused RAM. Alt-M lets you see the
result of this process. Non-unique variables are in-whole or in-part
derived from unique variables and get assigned within the unique-
variable memory.
Keep in mind that you may make alias names for the pin variables:
keyin var in5 ‘make “keyin” a way to read P5’s state.
Note for Stamp I users: W0-W12 (and the corresponding B0-B25) are pre-
defined by the compiler software to make use of Stamp I programs easier. If
you use a Stamp I program with the Stamp II, you can enter the older “Wx”
and “Bx” variable names without having to define them first.
The CON statment - defining constants
The CON statement is similar to the VAR statement, except that it is
for defining constant values and assigning them to symbolic names.
This is handy for having a single declaration which gets accessed
throughout your program. The CON syntax is as follows:
symbol CON expression ‘assign expression to “symbol”
- symbol is a unique symbolic name for a constant
- expression is a compile-time-resolvable constant
level CON 10 ‘“level” is same as 10 in program
limit CON 10*4<<2 ‘“limit” is 160
expressions after CON can contain the following binary operators and
are resolved left-to-right: