BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – IF...THEN
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 231
IF…THEN
BS1 BS2 BS2e BS2sx BS2p BS2pe BS2px
IF Condition(s) THEN Address
IF Condition(s) THEN Statement(s) { ELSE Statement(s) }
IF Condition(s) THEN
Statement(s)
{ ELSEIF Condition(s) THEN
Statement(s)… }
{ ELSE
Statement(s) }
ENDIF
Function
Evaluate Condition(s) and, if true, go to the Address or execute the
Statement(s) following THEN, otherwise process the ELSEIF/ELSE
block(s), if provided. ELSEIF is optional and works just like IF, but is only
evaluated if the Condition(s) in the preceding IF is false. The ELSE block is
optional and is executed if all Condition(s) in all preceding IF/ELSEIFs are
false. The program will continue at the next line of code (single-line
syntax) or the line that follows ENDIF (multi-line syntax) unless Address or
Statement(s) are executed that cause the program to jump.
• Condition is a statement, such as “x = 7” that can be evaluated as
true or false. Condition can be a very simple or very complex
relationship, as described below.
• Address is a label that specifies where to go in the event that
Condition(s) is true.
• Statement is any valid PBASIC instruction. Multiple statements
may be placed on the same line (though not recommended) by
separating each statement with a colon ( : ).
All
2
NOTE: PBASIC 1.0 and
PBASIC 2.0 only support
IF Condition(s) THEN Address.
PBASIC 2.5 supports all syntax
variations.
1
A
ll
2
All
2