BASIC stamp manual v2.2

BASIC Stamp Architecture – Constants and Expressions
Page 94 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
Suppose you’re working on a program called “Three Cheers” that flashes
LEDs, makes hooting sounds, and activates a motor that crashes cymbals
together, all in sets of three. A portion of your PBASIC program might
contain something like:
FOR counter = 1 TO 3
GOSUB Make_Cheers
NEXT
...
FOR counter = 1 TO 3
GOSUB Blink_LEDs
NEXT
...
FOR counter = 1 TO 3
GOSUB Crash_Cymbals
NEXT
The numbers 1 and 3 in the code above are called constants. They are
constants because, while the program is running, nothing can happen to
change those numbers. This distinguishes constants from variables, which
can change while the program is running.
Constants are not limited to the decimal number system; PBASIC allows
you to use several numbering systems. See “Number Representations” on
page 96.
You can assign names to constants in a fashion similar to how variables
are declared. On a BS1, it is identical to variable declarations. For all BS2
models, use the CON directive. Here is the syntax:
SYMBOL Name = ConstantValue
-- or --
Name CON ConstantValue
C
ONSTANTS AND COMPILE-TIME
EXPRESSIONS.
1
A
ll
2
1
All
2
DEFINING AND USING CONSTANTS (CON).