Programming 615
Typically, the loop contains commands 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.
Ê
Ë
:0!x
:Loop
: Disp x
: x+1!x
: If x>5
: Exit
:EndLoop
:Disp x
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.