A while loop will loop while a condition is true.
while($a < 10) //Do something end while
A common form of while loop is the while-true loop. This loop will continue indefinitely since there
is no condition from which it will stop. It can be broken by a
break command, however.
while(true) //Do something end while
As with all loops, while loops may be terminated by
while($a < 10) //Do something end loop
Version 1.5.1 added do while loops. These loops are incredibly simple to use and work exactly as a standard while loop does except with one subtle difference. A while loop may not necessarily execute a statement:
$a = 0 while($a > 10) //Do something end loop
With a do while loop it is guaranteed to execute at least once. Many other languages out there also implement a do while loop that works similarly. Below is an example of a do while loop in YASS:
$a = 0 do //Do something loop while($a > 10)
Another form of loop, similar in syntax to the while loop, is loop until. This loop will loop while a condition is false or until a condition is true.
$a = 0 loop until($a > 10) //Do something end loop
One of the first programs I ever wrote was in Visual Basic 6 and was a guess the number game. It took several lines of code to write. With ZPE this can be done very easily.
$n = random_number(1, 20) while(input("Please insert a number between 1 and 20.") != $n) print("Sorry, wrong answer. Guess again.") end while print("Correct. The number I was thinking of was " & $n & ".")