EasyManua.ls Logo

Apple IIe - Page 71

Apple IIe
320 pages
Print Icon
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...
Applesoft
BASIC
Programming
71
the
index
variable A
would
be
incremented
by 2 every
time
the
NEXT
statement
was
executed.
Nested Loops
One
loop
can be placed inside
another
loop. The
innermost
loop
is
known
as
a nested
loop
. The
following
program contains
a nested
loop
.
50
DIM
R
(2,3)
100
DAT A 10,
20,
30,
40,
50,
60
200
FOR
I = 1
TO
2
300
FOR
J = 1 TO 3
400
READ R (l,J)
450
PRINT R (l,
J)
500
N.
EXT
J
600
NEXT
I
Our
preceding
example
is
used
to
read data
into
the
numeric
array
R.
One
error
that you should take care
to
avoid
when
using nested
loops
is
to
end
an
outer
loop
before
an
inner
loop
is
ended.
Conditional Statements
One
of
the
most
important
features
of
a
computer
is
its
ability
to
make a decision. BASIC
uses
the
IF, THEN statement
to
take
advantage
of
the
computer's
decision
making
ability
. The IF,
THEN
statement takes
the
following
form:
IF
expression
THEN
statement
or
line
number
The
IF
statement
sets
up
a question
or
a
condition
. If
the
answer
to
that question
is
true
,
the
statement
or
line
number
following
THEN
is
executed. If
the
answer
is
false, all instructions
following
THEN are
ignored,
and program execution
will
resume
with
the
next line
number
in the program.
In
the
following
example,
if
1
is
input
for
X,
the
Y
is
set equal
to
1.
Otherwise, Y's value remains 0.

Other manuals for Apple IIe

Related product manuals