Specifications

BASIC Stamp II
Page 232 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
After the download is complete and the BS2 starts executing your pro-
gram—this is referred to as “runtime.” At runtime the BS2 processes
math and logic operations involving variables, or any combination of
variables and constants.
Because compile-time and runtime expressions appear similar, it can
be hard to tell them apart. A few examples will help:
cheers con 3
glasses con cheers*2-1 ' Compile time.
oneNinety con 100+90 ' Compile time.
noWorkee con 3*b2 ' ERROR: no variables allowed.
b1 = glasses ' Same as b1 = 5.
b0 = 99 + b1 ' Run time.
w1 = oneNinety ' 100 + 90 solved at compile time.
w1 = 100 + 90 ' 100 + 90 solved at runtime.
Notice that the last example is solved at runtime, even though the math
performed could have been solved at compile time since it involves
two constants. If you find something like this in your own programs,
you can save some EEPROM space by converting the run-time expres-
sion 100+90 into a compile-time expression like oneNinety con 100+90.
To sum up: compile-time expressions are those that involve only con-
stants; once a variable is involved, the expression must be solved at
runtime. That’s why the line “noWorkee con 3*b2” would generate an
error message. The CON directive works only at compile time, so vari-
ables are not allowed.
Order of Operations
Let’s talk about the basic four operations of arithmetic: addition (+),
subtraction (-), multiplication (*), and division (/).
You may recall that the order in which you do a series of additions and
subtractions doesn’t affect the result. The expression 12+7-3+22 works
out the same as 22-3+12+7. Howver, when multiplication or division
are involved, it’s a different story; 12+3*2/4 is not the same as 2*12/
4+3. In fact, you may have the urge to put parentheses around por-
tions of those equations to clear things up. Good!