Tandy 1000 Basic Reference Manual page 177

Hide thumbs Also See for 1000:
Table of Contents

Advertisement

Chapter
10 I
BASIC
Keywords
IF/THE N/E LSE
Statement
IF expression T H E N statemnt(s)[ELSE statemnt(s)]
Tests a conditional expression and makes a decision regarding
program flow.
Expresswn
is any numeric or string expression, usually making
logical or relational comparisons.
Statement
can be 1 or more valid BASIC statements.
If
there is
more than 1 statement, they must be separated by colons. You
c a n also specify a line number for BASIC t o branch a s a
statement
.
If
expression
is true, BASIC executes the THEN
statement. If
expresswn
is
false, BASIC executes the matching ELSE
statement
or the next program line.
You can also use IFiTHEN t o test the numeric value of a vari-
able.
If
the variable contains a 0, the expression is true; other-
wise, the expression is false.
Examples
I F X
>
1 2 7 T H E N P R I N T "OUT
OF RANGE"
:
END
passes control to PRINT and, then t o END if X is greater than
127. If
X
is not greater than 127, BASIC executes the next line
in the program, skipping the PRINT and END statements.
I F A
<
B
T H E N P R I N T " A
< E"
E L S E P R I N T
"E
< =
A "
tests the first expression.
If
it is true, BASIC prints A
< B .
Otherwise, BASIC jumps t o the ELSE statement and prints
B < = A .
175

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents