BASIC stamp manual v2.2
Using the BASIC Stamp Editor
Page 72 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
False (0). Upon compiling this example, the #IF…#THEN statement will
evaluate DebugMode, which is False (because it is undefined) and then will
not allow the DEBUG statement to be compiled. Only the STOP
command will be compiled into the program in this example. This is a
very powerful feature for quickly removing many DEBUG statements (or
other statements) from a program when you’re done developing it, but
leaving the possibility of re-enabling all those statements should further
maintenance be required at a later time.
The optional Value argument can be used, for example, to select modes of
operation:
' {$PBASIC 2.5}
#DEFINE SystemMode = 2
#IF SystemMode = 1 #THEN
HIGH 1
#ELSE
LOW 1
#ENDIF
In the example above, the first line defines SystemMode to be equal to 2.
The #IF…#THEN statement evaluates the state of SystemMode, determines
it is 2, so the condition is false, and then it skips the statement after #THEN
and allows the statement following #ELSE to be compiled into the
program.
Note, conditional compile directives are evaluated just before the program
is compiled, so variables and named constants cannot be referenced within
a conditional compile definition. Compile-time symbols created with
#DEFINE can, however, be referenced by conditional compile commands.
#IF Condition(s) #THEN
Statement(s)
{ #ELSE
Statement(s) }
#ENDIF
#IF...#THEN SYNTAX.