"Sputnik" help  
Sputnik Help
Do
{
statements
...
} Until (<condition>);

Description

Unlike for, while and until loops, which test the loop condition at the top of the loop, the do...until loop checks its condition at the bottom of the loop.

A do...until loop is similar to a until loop, except that a do...until loop is guaranteed to execute at least one time.

Parameters

<condition>

The condition is evaluated just like an If statement. If it is false, the body of the loop is executed again. If it is true, the body of the loop does not execute again (it is guaranteed to execute the body once regardless if the condition is false or not) and flow of control jumps to the next statement just after the for loop.

Remarks

Do...Until statements may be nested.

The Do...Until loop in Sputnik is a control structure that allows you to repeatedly execute a block of code until a specified condition becomes true. It is the reverse of the Do...While loop, where the loop continues executing the code block until the condition is satisfied.

In the Do...Until loop, the code block is executed first, and then the condition is evaluated. If the condition is false, the loop continues executing the code block. The loop terminates when the condition becomes true.

Related

Loop Statements
Continue Statement
Redo Statement
Break Statement

Example

Basic Example:

// Local variable declaration:
my $a = 10;
// do loop execution
Do
{
   say "value of a: $a";
   $a = $a + 1;
} Until($a > 19);
// PRINTS
// value of a: 10
// value of a: 11
// value of a: 12
// value of a: 13
// value of a: 14
// value of a: 15
// value of a: 16
// value of a: 17
// value of a: 18
// value of a: 19

As we see here the code always executes once:

my $a = 1;
Do
{
   say "value of a: $a";
} Until($a == 0);
// PRINTS
// value of a: 1

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org