POSITION:028,114
COLOUR:STANDARD
TEXT:00,Program branching is only one part of changing the way your program runs.
TEXT:16,You can also make a group of statements repeat for as long as an
TEXT:16,expression remains true. This is done by using the "while" statement:
COLOUR:EUPHORIA
TEXT:32,while            do
COLOUR:POINTS
TEXT:00,      expression
TEXT:16,     one or more statements that are executed while condition is true
COLOUR:EUPHORIA
TEXT:16,end while
COLOUR:STANDARD
TEXT:32,When the "while" statement first starts, it checks            to see if
COLOUR:POINTS
TEXT:00,                                                   expression
COLOUR:STANDARD
TEXT:16,it is true. If it is not, the next programming statement following
COLOUR:EUPHORIA
TEXT:00,                                                                   end
TEXT:16,while
COLOUR:STANDARD
TEXT:00,      is executed. If the expression is true, the "while" statement
TEXT:16,will continue to repeat the statements between "while" and "end while"
TEXT:16,until the expression portion of the "while" statement becomes false. This
TEXT:16,tells you that the repeating statements must be able to make the
TEXT:16,expression change to false, or the program will be stuck in an endless
TEXT:16,"while" loop. A demo program using a "while" statement is available.
