Delay
Loops
Erase all the
PRI
NT
statements so that absolutely nothing
is
in
the
FOR-NEXT sandwich
loop, except the
FOR
and the NEXT statements.
Run
the program and see what happens:
1.5
1.6
1.7
1.8
1.~
29
21.
22
23
LIST
RUN
Nothing happens. Change the number
in
line 10 and watch carefully
again:
1.9
FOR
JKL=1.
TO
599
RUN
The Ready prompt takes a few seconds to appear. Change line 10
again:
1.9
FOR
JKL=1.
TO
5999
RUN
This time the Ready prompt takes considerably longer to appear. The
computer
is
counting but not printing its calculations. The process
is
similar to counting silently to yourself. The time it takes the Ready
prompt to appear on the screen
is
the time it takes the computer to
count to
5000.
FOR-NEXT loops are excellent devices for keeping the computer from
moving on.
In
fact, FOR-NEXT loops are used so frequently for this
purpose that they are sometimes
called
"delay
loops,"
and the
common
variable name
is
DELAY. Rewrite the FOR-NEXT loop, using
DELAY as the
variable name and different numbers
in
the
FOR
statement:
NEW
1.9
FOR
DELAV=1.
TO
399
29
NEXT
DELAV
LIST
RUN
61