340 Programming
Loop...EndLoop loops
A Loop...EndLoop creates an infinite loop, which is repeated endlessly.
The
Loop command does not have any arguments.
Typically, you insert commands in the loop that let the program exit from
the loop. Commonly used commands are:
If, Exit, Goto, and Lbl (label).
For example:
À An If command checks the condition.
Á Exits the loop and jumps to here when x increments to 6.
Note: The
Exit command exits from the current loop.
In this example, the
If command can be anywhere in the loop.
The
If command could also use a Goto command to transfer program
control to a specified Lbl (label) command.
When the If command is: The loop is:
At the beginning of the loop Executed only if the condition is true.
At the end of the loop Executed at least once and repeated
only if the condition is true.
Loop
--------
--------
EndLoop
--------
0&x
Loop
Disp x
x+1
&x
If x>5
À
Exit
EndLoop
Disp x
Á