BASIC stamp manual v2.2
3: Using the BASIC Stamp Editor
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 71
Lets look at the syntax and examples for each conditional compile
directive. For an explanation of syntax conventions, see page 128.
#DEFINE Symbol { = Value }
#DEFINE allows the programmer to create custom, compile-time, symbols
for use within conditional compile control structures.
• Symbol is a unique symbol name that will optionally represent
a Value.
• Value is an optional constant/expression specifying the value
of Symbol. If the value parameter is omitted, Symbol is defined
as true (-1).
Example:
' {$PBASIC 2.5}
#DEFINE DebugMode
#IF DebugMode #THEN DEBUG "Debugging."
STOP
In the example above, the #DEFINE statement defines DebugMode to be
“true” (-1), since there is no Value argument provided. The second line is
another conditional compile statement, #IF…#THEN (see below for more
information) which evaluates the state of DebugMode, determines it is true
and then allows the following DEBUG statement to be compiled into the
program. The last line, STOP, is compiled into the program afterwards.
The result of compiling this example is a program with only two
executable statements, DEBUG "Debugging", CR and STOP. The real
power of this example, however, is more obvious when you comment out,
or remove, the #DEFINE line. Look at the next example, below:
' {$PBASIC 2.5}
' #DEFINE DebugMode
#IF DebugMode #THEN DEBUG "Dubugging."
STOP
Here we commented out the #DEFINE line, effectively removing that line
from the program. This means that the symbol DebugMode will be
undefined, and undefined conditional compile symbols are treated as
#DEFINE SYNTAX.