Touch Develop retirement postponed until June 22, 2019. Sign-in and access to cloud assets to be removed on May 23, 2018.Learn More..


while

while is a statement that executes a body of code in a loop until the condition is false.
Because the condition is evaluated before entering the loop, the body may be executed zero or more times.
while condition do
...
end while

example: counting backwards

In this example, we simply count backwards from 10 to 0. To implement such program, you start by declaring an index before the while loop.
var index := 10
while index0 do
index → post to wall
Since we want to enumerate positive numbers, the condition is simply that `index` should greater or equal to 0. Then, on each iteration we substract `1` to `index` so that eventually it gets to 0.
index := index - 1
end while