Sharp PC-1403 Operation Manual page 148

Hide thumbs Also See for PC-1403:
Table of Contents

Advertisement

142
1
1
#1
The FOR and NEXT verbs are used in pairs to enclose
a
group of
statements
which are
to be
repeated.
The first time this group of
statements
is
executed,
the loop variable
(the variable named immediately following the
FOR) has
the value
of
expression 1.
When
execution reaches the NEXT verb,
the
loop variable is increased by the step size
and then this value is tested against expression 2.
If
the value of the loop variable is
less
than or equal
to expression 2, the
enclosed
group
of
statements
i
s executed
again, starting with the
statement
following
the FOR. In
the first
form,
the step size
is
1 ;
in
the second
form,
the step
size i
s given
by expression
3.
If
the value of the
loop
variable
is
greater than expression
2,
execution
continues with the
statement which
immediately follows the NEXT. Because
the
comparison is made
at
the end, the
statements
within
a
FOR/NEXT pair
are always
executed
at least
once.
Expression
1,
expression
2, and expression
3 must be
in
the range
of
-9.999999999E99 to
9.999999999E99. If
the value of expression 3 is
zero,
FOR/
NEXT
loop
will
be
infinite.
The
loop
variable may be used
within the
group of
statements, for
example,
as an
index
to an
array,
but care should be
taken in
changing the value of the loop
variable.
Programs should be written so that they
never
jump
from
outside a FOR/NEXT pair to a
statement
within
a
FOR/NEXT
pair.
Similarly, programs must never leave a
FOR/
NEXT
pair
by jumping out.
Always
exit a FOR/NEXT
loop
via
the
NEXT statement.
To
do
this,
set the loop variable to a value
higher
than expression
2.
The
group
of
statements enclosed by a FOR/NEXT
pair can
include another pair of
FOR/NEXT statements
which
use a different loop variable as long as the enclosed
pair
is
completely
enclosed; i.e.,
if a FOR statement is
included
in the
group,
the
matching
NEXT
must also be
included.
FOR/NEXT
pairs may
be
"nested"
up
to
five
levels
deep.
•MUM·MM
The
FO_R
verb
is
used in combination
with
the NEXT verb to repeat
a
series of
operations a specified number
of times.
1
FOR
numeric
variable=expression 1 TO expression
2
2
FOR
numeric
variable=expression 1 TO expression
2
STEP expression
3
Abbreviations:
F.
and
FO.; STE.
See
also:
NEXT
Verbs
FOR
••.
TO

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents