Until Loop
From Sputnik Wiki
(Difference between revisions)
(Created page with "= Until...UEnd = === Description === Loop based on an expression. <pre> Until <expression> statements ... UEnd </pre> === Parameters === ==== expression ==== If th...") |
m (1 revision) |
||
(5 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | = Until | + | = Until = |
=== Description === | === Description === | ||
Line 6: | Line 6: | ||
<pre> | <pre> | ||
− | Until <expression> | + | Until ( <expression> ) |
+ | { | ||
statements | statements | ||
... | ... | ||
− | + | } | |
</pre> | </pre> | ||
Line 16: | Line 17: | ||
==== expression ==== | ==== expression ==== | ||
− | If the expression is false the following statements | + | If the expression is false the following statements are executed. This loop continues until the expression is true. |
+ | |||
+ | Same as a WHILE you can omit the expression however this loop will never execute if you do that. | ||
=== Remarks === | === Remarks === | ||
− | Until | + | Until statements may be nested. |
The expression is tested before the loop is executed so the loop will be executed zero or more times. | The expression is tested before the loop is executed so the loop will be executed zero or more times. | ||
− | To create an infinite loop, you can use a zero number as the expression such as "Until False" | + | To create an infinite loop, you can use a zero number as the expression such as "Until ( False )" |
+ | |||
+ | 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 === | === Example === | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $i = 0 | + | $i = 0; |
− | Until $i > 20 | + | Until ( $i > 20 ) |
− | println( "Value is: " . $i ) | + | { |
− | $i++ | + | println( "Value is: " . $i ); |
− | + | $i++; | |
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | A reverse Until | ||
+ | <syntaxhighlight lang="sputnik"> | ||
+ | my $i = 0; | ||
+ | println("Value $i {\$i++!}") until($i == 10); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:38, 14 June 2015
Contents |
Until
Description
Loop based on an expression.
Until ( <expression> ) { statements ... }
Parameters
expression
If the expression is false the following statements are executed. This loop continues until the expression is true.
Same as a WHILE you can omit the expression however this loop will never execute if you do that.
Remarks
Until statements may be nested.
The expression is tested before the loop is executed so the loop will be executed zero or more times.
To create an infinite loop, you can use a zero number as the expression such as "Until ( False )"
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; Until ( $i > 20 ) { println( "Value is: " . $i ); $i++; }
A reverse Until
my $i = 0; println("Value $i {\$i++!}") until($i == 10);