The WHILE loop in ProBuilder language is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The loop will continue to execute as long as the condition remains true. This is particularly useful for iterating through data or performing repetitive tasks until a specific condition changes.
WHILE condition DO
// Statements to execute
WEND
i = 0
count = 0
WHILE i <> 11 DO
i = i + 1
count = count + 1
WEND
RETURN count
In this example, the WHILE loop starts with i initialized to 0. The loop continues to execute as long as i is not equal to 11. Inside the loop, i is incremented by 1 in each iteration, and count is also incremented by 1. Once i reaches 11, the condition i <> 11 becomes false, and the loop exits. Finally, the value of count, which represents the total number of iterations, is returned.
WEND keyword is used to mark the end of the WHILE loop.