A B C D E F G I J K L M N O R S T U V W
Da Do Dr

 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

Note: Because of the way LSL parser works (more details: http://w-hat.com/stackdepth), conditions in LSL are evaluated left to right, instead of right to left as in most programming languages. Check example on condition page.

 

Credit to: Lslwiki.net (not working) with changes made for brevity and clarity.