I'm a doctor, not a mechanic

While loop

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 23:28, 11 October 2008 by Wormbo (Talk | contribs) (New page: The '''while''' loop is a basic loop statement in UnrealScript, similar to the for loop and the do...until loop. ==Syntax== The '''while''' loop syntax is very similar to that...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The while loop is a basic loop statement in UnrealScript, similar to the for loop and the do...until loop.

Syntax

The while loop syntax is very similar to that of the if statement:

while (condition) {
  ...
}

The condition must be a bool type expression. The code between the parentheses is executed repeatedly until either the condition becomes False or a break statement is encountered.

Similar to the if statement, a while loop can be used to repeat a single statement instead of a block of code:

while (condition)
  statement;

This notation should be used with care because the statement could be the empty statement (a single semicolon), which would mean the loop only repeatedly evaluates its condition.