EasyManua.ls Logo

Radio Shack TRS-80 Model 3 - Page 171

Radio Shack TRS-80 Model 3
276 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
THEN statementor line number
Initiates the" action clause"
of
an
IF-THEN
type statement.
THEN
is
optional except
when it is required to eliminate an ambiguity, as in
IF A<
0100.
THEN
should be
used in
IF-THEN-ELSE
statements.
ELSE statement
or
line number
Used after
IF
to specify an alternative action in case the
IF
test fails. (When no
ELSE
statementis used, control falls through to the next program line aftera test fails.)
Examples:
100
INPUT
AS:
IF
AS
=
"YES"
THEN
300
ELSE
END
In line 100,
if
A$ equals "YES" then the program branches to line 300. But
if
A$
does not
equal'
'YES"
, program skips over to the
ELSE
statement which then
instructs the
Computer
to end execution.
20~~
I
F'
t~
< B
"rHE:N
PI~
I
NT
"ti<l3
11
FL..BE:
pr~
I
N'r
"P,<:::~l~
II
If
Ais less than
B,
the Computerprints that fact, and then proceeds down to the next
programline,
skipping the
ELSE
statement.
If
Ais not less than
B,
Computer
jumps
directly to the
ELSE
statementand prints the specified message. Then control
passes to the next statementin the program.
200
IF
A>"001
THEN
B =
1/A:
A =
A/S:
ELSE
260
If
A>
.001 is
True,
then the nexttwo statements will beexecuted, assigning new
values to
Band
A.
Then
the program will drop
down
to the next line, skipping the
ELSE
statement.
But
if
A>
.001 is False, the program
jumps
directly over to the
ELSE
statement, which then instructs it to branch to line 260. Note that
GOTO
is not
required after
ELSE.
IF-THEN-ELSE
statements may be nested, butyou have to take care to match up the
IFs
and
ELSEs.
810
INPUT
"ENTER
TWO
NUMBERS";
A,
B
820
IF
A
<=
B
THEN
IF
A < B
PRINT
A;:
ELSE
PRINT
"NEITHER
";:
ELSE
PRINT
B;
830
PRINT
"IS
SMALLER"
840
END
RUN
the program, inputting various pairs
of
numbers.
The
program picks out and
prints the smaller
of
any two numbers youenter.
4/15

Related product manuals