EasyManua.ls Logo

Atari 800

Atari 800
326 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...
Alari BASIC Reference
Guide
117
A FOR/NEXT
loop
can use a
STEP
statement to
increment
the
counter
by a value
other
than
1.
EXAMPLE
10
FOR J = 1
TO
2
STEP
.5
20
PRINT L
30
NEXT
J
RUN
1 1.5 2
The
preceding
example contains a FOR/
NEXT
loop
which
increments
the
value
of
J by
.5
each
time
the
loop
is
executed.
A
FOR
/
NEXT
loop
can also be used to decrease the value
of
the
counter.
This can be accomplished by using the
optional
STEP
statement
within
the
FOR
statement.
If
the
STEP
statement
has
a
negative
argument,
the
counter
is
decreased each
time
the
loop
is
executed. The
following
example illustrates a FOR/NEXT
loop
where
the
counter
is
decremented
rather than
incremented
.
EXAMPLE
10
FOR
K =
10
TO 5
STEP
-2
20
PRINTK
,
30
NEXT
K
RUN
10
8 6
This
loop
begins
at
line
10
by assigning
the
counter
(K)
the
value
10.
At
line
20
the value
of
K
is
printed.
When
line
30
is
encountered,
execution
continues
at
line
10
, because the
NEXT
statement returns the
program
to
the
preceding
FOR
statement.
The
value
of
the
counter
is
changed by
the
argument
of
STEP.
Since the
STEP
value
is
-2
,
the
counter
is
decreased by 2. The
value
of
the
counter
is
changed
to
8.
At
line
20,
the
new
value
of
K
is
printed.
Line
30
is
executed again,
so
the
program
returns
to
the
FOR statement at
line
10
. The
counter
is
again
decremented
by 2. The
new
value
of
K
is
6.
At
line
20,
this K value
is
printed.
When
line
30
is
executed again, the
program
does
not
return
to

Other manuals for Atari 800

Related product manuals