100
The
VIC
20
User
Guide
is
called.
If
A = 3 the subroutine beginning
at
line 5000
is
called.
If
A = 4
the subroutine beginning
at
line 2300
is
called.
If
A has any value other than
1,2,3,
or
4, the program will merely continue executing
at
line
110.
The
computed GOSUB statement remembers the next line number (in this case,
110).
It
does not matter which of the subroutines
is
called; the called
subroutine's
RETURN
statement will branch back to the stored line
number (in this case,
110).
You can nest computed GOSUB statements, just as you can nest
standard GOSUB statements.
IF·
THEN
statement
The arithmetic and relational operators described earlier in this chapter
are frequently used in IF-THEN statements. This gives a BASIC program
decision-making capabilities. Following
IF
you enter any expression.
If
the
expression
is
true, the statement(s) following THEN are executed. However,
ifthe
expression
is
false the statement(s) following
THEN
are not executed.
Here are three simple examples of IF-THEN statements.
10
IF
Fh=B+5
THEN
PRINT
MSO"
40
IF
CCS("M"
THEN
IN"0
50
IF
Q(14
~ND
M()Ml
OOTO
66
The statement on line
10
causes a
PRINT
statement to be executed if
the value
of
floating point variable A
is
five more
than
the value
of
floating
point variable
B.
The
PRINT
statement will not be executed otherwise. The
statement on line
40
sets floating point variable IN to 0 if string variable CC$
is
any letter of the alphabet in the range A though
L.
The statement on line
50
causes program execution to branch to line
66
if floating point variable Q
is
less than
14
and floating point variable M
is
not equal to floating point
variable
MI.
Otherwise, program execution will continue with the state-
ment on the next line (GOTO can substitute for THEN).
If
you do not understand the evaluation
of
expressions following IF,
then refer
to
the discussion
of
these expressions
at
the beginning of this
chapter.
Input/Output Statements
There are a variety of BASIC statements
that
control the transfer
ef
data to and from the computer. Collectively, these are referred to as
input/ output statements. The simplest input/ output statements control