Texas Instruments TI-92 Calculator User Manual


 
Chapter 17: Programming 297
17PROGRM.DOC TI-89/TI-92 Plus: Programming (English) Susan Gullord Revised: 02/23/01 1:14 PM Printed: 02/23/01 2:18 PM Page 297 of 40
To enter most of the loop-related
commands, use the Program
Editor’s
Control
toolbar menu.
When you select a loop, the loop
command and its corresponding
End
command are inserted at the
cursor location.
:For
|
:EndFor
You can then begin entering the commands that will be executed in
the loop.
A
For...EndFor
loop uses a counter to control the number of times
the loop is repeated. The syntax of the
For
command is:
For
(variable, begin, end [, increment])
When
For
is executed, the
variable
value is compared to the
end
value. If
variable
does not exceed
end
, the loop is executed;
otherwise, program control jumps to the command following
EndFor
.
:For i,0,5,1
: --------
: --------
:EndFor
:--------
At the end of the loop (
EndFor
), program control jumps back to the
For
command, where
variable
is incremented and compared to
end
.
Using Loops to Repeat a Group of Commands
To repeat the same group of commands successively, use a
loop. Several types of loops are available. Each type gives you
a different way to exit the loop, based on a conditional test.
Control Toolbar
Menu
Note: A loop command
marks the start of the loop.
The corresponding
End
command marks the end of
the loop.
For...EndFor Loops
Note: The ending value can
be less than the beginning
value, but the increment
must be negative.
Note: The
For
command
automatically increments th
e
counter variable so that the
program can exit the loop
after a certain number of
repetitions.
added to the counter each subsequent time
For
is executed (If this optional value is
omitted, the increment is 1.)
exits the loop when
variable
exceeds this value
counter value used the first time
For
is executed
variable used as a counter
If the loop requires
arguments, the cursor is
positioned after the command.
i
5i > 5