Do-While
A do-while
loop is similar to a
while loop, but the order in which the parts are executed is different.
Format
do
{
statements
} while (condition);
Example
do
{
llSay(0, "monkey!");
} while (monkeysRemain());
This
code will say "monkey!" once, and then continue saying "monkey!" as long as the
function monkeysRemain() returns TRUE.
In a do-while loop, the
statements are always executed at least once, then the
condition is checked, and if it
evaluates true, the
statements are repeated.
A do-while loop is used to execute the
statements one time, and then additional times. For a loop that executes statements only when a specific condition is true, see the
while loop.
Finding a time to use this is rare. It's a wrong solution when I use it (so the section ends up getting re-written). -
BW
Accoding to Strife replacing a while loop with a do{}while wrapped in an if statement reduces bytecode size. -
Chris
It also executes faster than a while loop, (the bytecode savings is 5 bytes) -
BW aka Strife
Flow Control |
While