User's Manual

232
Chapter 12: Programming
7312ENG.DOC CH 12 Programming, English Julie Hewlett Revised: 07/29/98 12:17 PM Printed: 05/19/99 9:02
AM Page 232 of 32
While While 8
5 5
Use
While
to test condition before the commands in the loop
are executed.
While
performs a block of commands WHILE
condition is true (non-zero). condition is frequently a
relational test (Chapter 2: Math Operations) and is tested
when
While
is encountered.
End
identifies the end of block.
When condition is false (zero), the program executes each
command following
End
.
While
instructions can be nested.
:While
condition
:
block (while condition is true)
:End
:
command
Write a program named
LOOP
that increments two variables, I
and J, and displays the value of J when I6.
PROGRAM:LOOP
:0
"
I
:0
"
J
:While I<6
:J+1
"
J
:I+1
"
I
:End
:Disp "J=",J
:Pause
Repeat Repeat 8
6 6
Use
Repeat
to test condition after the commands in the loop
are executed.
Repeat
executes block UNTIL condition is true
(non-zero). It is similar to
While
, but condition is tested when
End
is encountered; therefore, the group of commands is
always executed at least once. When condition is false (zero),
Repeat
instructions can be nested.
:Repeat
condition
:
block (until condition is true)
:End
:
command
³