EasyManua.ls Logo

Sharp MZ-800 - Page 71

Sharp MZ-800
221 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...
FOR
~
NEXT
Format
Abbreviated
Format
FOR
<control
variable>
=
<initial
value>
TO
<final
value>
IBTEE,
<increment
>]
NEXT
<control
variable
>
Explanation
Example
F.~N.
The
FOR
~
NEXT
statements
repeat
the
instructions
between
the
FOR
and
NEXT
variables
the
specified
number
of
times.
10
A=0
20
FOR
N=0O
TO
10
STEP
2
30
A=A+1
40
PRINT
“N="";N,
50
PRINT
“A=""A
60
NEXT
N
(1)
In
the
program
above,
0
is
assigned
to
N
as
the
initial
value.
(2)
Next,
lines
20
through
50
are
executed
and
the
values
of
variables
A
and
N
dis-
played.
(3)
In
line
60,
the
value
of
N
is
increased
by
2,
after
which
the
BASIC
interpreter
checks
to
see
whether
N
is
greater
than
10,
the
final
value.
If
not,
lines
follow-
ing
line
20
are
repeated.
When
the
value
of
N
exceeds
10,
the
program
leaves
the
loop
and
the
subsequent
instructions
(on
lines
following
line
60)
are
executed.
The
program
above
repeats
the
loop
6
times.
If
STEP
<increment>
is
omitted
from
the
statement
specification,
the
value
of
<control
variable>
is
increased
by
|
each time
the
loop
is
repeated.
In
the
pro-
gram
above,
omitting
STEP2
would
result
in
11
repetitions
of
the
loop.
FOR
Nag
TO
10
STEP
2
Initial
value
Final
value
Increment
of
N
for
N
for
N
NEXT
N
FOR
~
NEXT
loops
may
be
nested within
other
FOR
~
NEXT
loops.
When
doing
this,
inner
loops
must
be
completely
enclosed
within
outer
ones,
and
not
overlap.
Also,
separate
control
variables
must
be
used
for
each
loop.
6-14

Other manuals for Sharp MZ-800

Related product manuals