WEND

Category: Instructions

WEND is a keyword used in the ProBuilder programming language to mark the end of a WHILE loop. The WHILE loop repeatedly executes a block of code as long as a specified condition remains true. The WEND statement signifies the point at which the loop should evaluate the condition again to decide whether to continue executing or to exit the loop.

Syntax:

WHILE condition DO
    [statements]
WEND

Example:

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 the Count variable is also incremented by 1. Once i reaches 11, the condition i <> 11 becomes false, and the loop terminates with the WEND statement. The final value of Count, which is 11, is then returned.

Additional Information:

  • The WHILE loop is useful for executing a block of code multiple times based on a dynamic condition that may change with each iteration of the loop.
  • It is important to ensure that the loop has a condition that will eventually become false; otherwise, the loop will create an infinite loop, potentially causing the program to crash or hang.

Related Instructions:

  • WHILE instructions
  • Logo Logo
    Loading...