EasyManuals Logo

Atari 400 Basic Reference Manual

Atari 400
122 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
Page #23 background imageLoading...
Page #23 background image
FOR
(F.),
TO,
STEP/NEXT
(N.)
4
PROGRAM
STATEMENTS
This
section
explains
the
commands
associated
with
loops,
conditional
and
un-
conditional
branches,
error
traps,
and
subroutines
and
their
retrieval.
It
also ex-
plains
the
means
of
accessing
data
and
the
optional
command
used
for
defining
variables.
The
following
commands
are
described
in
this
section:
FOR,
TO,
STEP/NEXT
GOSUB/RETURN
GOTO
IF/THEN
ON,GOSUB
ON,GOTO
POP
RESTORE
TRAP
Format:
FOR
avar
=
aexp1
TO
aexp2
[STEP
aexp3]
NEXT
avar
Examples:
FOR X = 1
TO
10
NEXT X
FOR Y = 10
TO
20
STEP 2
NEXT Y
FOR INDEX
= Z
TO
100 * Z
NEXT INDEX
This
command
sets
up
a
loop
and
determines
how
many
times
the
loop
is exe-
cuted.
The
loop
variable
(avar) is
initialized
to
the
value
of
aexp1.
Each
time
the
NEXT
avar
statement
is
encountered,
the
loop
variable
is
incremented
by
the
aexp3
in
the
STEP
statement.
The
aexp3
can
be
positive
or
negative
integers,
decimals,
or
fractional
numbers.
If
there
is
no
STEP
aexp3
command,
the
loop
increments
by
one.
When
the
loop
completes
the
limit
as
defined
by
aexp2,
it
stops
and
the
program
proceeds
to
the
statement
immediately
following
the
NEXT
statement;
it
may
be
on
the
same
line
or
on
the
next
sequential
line.
Loops
can
be
nested,
one
within
another.
In
this
case,
the
innermost
loop
is
com-
pleted
before
returning
to
the
outer
loop.
The
following
example
illustrates
a
nested
loop
program.
10
FOF.:
>=:=
1
TO
3
:::IJ
PF.:HH
11
0UTER
LOOP"
30
Z=f1
40
Z=Z+2
50
FOP
'·.1-i
1-1
6~3
PF.:It·H
II
7f1
t·~E>::T
'··'
I
:::0
t·4E>::T
>=:
90
am
TO
C"
,-
......
~:,
-,
·-'
.::
I t.:-
.::..
I
Nt·iE~:
LOOP
n
Figure
4-1.
Nested
Loop
Program
Program
Statements
15

Table of Contents

Other manuals for Atari 400

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Atari 400 and is the answer not in the manual?

Atari 400 Specifications

General IconGeneral
ManufacturerAtari
Model400
TypeHome Computer
Release Year1979
CPUMOS Technology 6502
CPU Speed1.79 MHz
ROM10 KB
Operating SystemAtari OS
KeyboardMembrane keyboard
RAM8 KB (expandable to 48 KB)
GraphicsANTIC and GTIA chips
Sound4 channels
DisplayRF output for connection to TV
StorageOptional cassette tape drive or floppy disk drive
PortsCartridge
Display Resolution320x192 (16 colors)

Related product manuals