Do While Loop

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "= Do While = === Description === Loop based on an expression. <pre> Do { statements ... }While ( <expression> ) </pre> === Parameters === ==== expression ==== If t...")
 
(Example)
Line 38: Line 38:
 
$i++;
 
$i++;
 
}While ( $i < 20 )
 
}While ( $i < 20 )
 +
</syntaxhighlight>
 +
 +
A do while loop can run forever and ever (until a BREAK is called) by omitting the expression
 +
 +
<syntaxhighlight lang="sputnik">
 +
$i = 0;
 +
Do
 +
{
 +
println( "Value is: " . $i );
 +
$i++;
 +
}
 +
While ( )
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 12:35, 30 September 2013

Contents

Do While

Description

Loop based on an expression.

Do
{
    statements
    ...
}While ( <expression> )

Parameters

expression

If the expression is true the following statements are executed. This loop continues until the expression is false.

Remarks

Do While statements may be nested.

The expression is NOT tested before the loop is executed so the loop will be executed one or more times.

To create an infinite loop, you can use a non-zero number as the expression such as "While (True)"

The expression can contain the boolean operators of &&, ||, ! as well as the logical operators <, <=, >, >=, ==, !=, <>, eq, eqi, neq and neqi as needed grouped with parentheses as needed.

Example

$i = 0;
Do
{
	println( "Value is: " . $i );
	$i++;
}While ( $i < 20 )

A do while loop can run forever and ever (until a BREAK is called) by omitting the expression

$i = 0;
Do
{
	println( "Value is: " . $i );
	$i++;
}
While ( )
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox