Loop through a block of code as long as WHILE condition is TRUE.

WHILE (condition) {
// code to execute for each iteration

The WHILE condition is only evaluated at the beginning of each iteration. Since the condition is checked at the begging of each iteration, if the condition evaluates to FALSE for the first iteration then the WHILE block of code won't ever run. If your WHILE condition changes halfway through executing the WHILE loop's block of code, you should either use CONTINUE, BREAK or if possible wait for the next iteration, which checks the condition before running, to exist the loop.


$x = 1
WHILE($x < 10) {
    ::p "X is" . $x
play_arrow RUN   open_in_new OPEN IN TAB

Copyright ©2013-2022 SunSed®. All rights reserved.