EasyManua.ls Logo

Commodore 128D - Empty Loops-Inserting Delays in a Program; The STEP Command

Commodore 128D
427 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...
u
Empty
Loops—Inserting
Delays
In
a
Program
Before
you
proceed
any
further,
it
will
be
helpful
to
understand
about
i
]
loops
and
some
ways
they
are
used
to
get
the
computer
to
do
what
'—'
you
want.
You
can
use
a
loop
to
slow
down
the
computer
(by
now
you
have
witnessed
the
speed
with
which
the
computer
executes
i
\
commands).
See
if
you
can
predict
what
this
program
will
do
before
l—J
you
run
it.
10
A$
=
"COMMODORE
C128"
LJ
20
FOR
J
=
1
TO
20
30
PRINT
40
FOR
K
=
1
TO
1500
U
50
NEXT
K
60
PRINT
A$
70
NEXT
J
|_j
80
END
Did
you
get
what
you
expected?
The
loop
contained
in
lines
40
and
i
i
50
tells
the
computer
to
count
to
1500
before
executing
the
remain-
^
der
of
the
program.
This
is
known
as
a
delay
loop
and
is
often
useful.
Because
it
is
inside
the
main
loop
of
the
program,
it
is
called
a
v
)
nested
loop.
Nested
loops
can
be
very
useful
when
you
want
the
^—J
computer
to
perform
a
number
of
tasks
in
a
given
order,
and
repeat
the
entire
sequence
of
commands
a
certain
number
of
times.
t
j
Section
5
describes
an
advanced
way
to insert
delays
through
use
of
the
new
BASIC
7.0
command,
SLEEP.
i
/
The
STEP
Command
You
can
tell
the
computer
to
increment
your
counter
by
units
(e.g.
10,
0.5
or
any
other
number).
You
do
this
by
using
a
STEP
command
with
the
FOR
statement.
For
example,
if
you
want
the
computer
to
count
bytens(to100,type:
10
FOR
X
=
0
TO
100
STEP
10
20
?X
30
NEXT
Notice
that
you
do
not
need
the
X
in
the
NEXT
statement
if
you
are
only
executing
one
loop
at
a
time—NEXT
refers
to
the
most
recent
FOR
statement.
Also,
note
that
you
do
not
have
to
increase
(or
"increment")
your
counter—you
can
decrease
(or
"decrement")
it
as
well.
For
example,
change
line
10
in
the
program
above
to
read:
10
FOR
X
=
100
TO
0
STEP-10
54
USING
C128
MODE-Advanced
BASIC
Programming

Table of Contents

Other manuals for Commodore 128D

Related product manuals