Wikis / Unreal Wiki / Do...Until loop

The do...until loop is a loop construct similar to the while loop, but runs at least once.

Syntax

The syntax of the do...until loop is exactly what you would expect from its name:

do {
  ...
} until (condition);

Note that UnrealScript doesn't "do...while", that means it loops until the condition is True. (or while it is False)

Like in any other loop construct you can use break and continue to exit the loop or jump to the next iteration.

Quirks

In Unreal Engine 1 and 2 the compiler wasn't too strict when checking the until statement. You could omit it, essentially creating an infinite loop that had to be exited with the break or return statement. This "feature" was removed in Unreal Engine 3.

A variation of the do...until loop is available in all engine generations. Like with the other loop constructs, you can specify a single statement instead of the code block after the keyword do:

do
  statement;
until (condition);

Note that the statement needs to be terminated with a semicolon, similar to the non-block version of the If statement that requires a semicolon after its statement even if an else statement follows. It is strongly recommended to enclose even a single statement in curly braces to prevent potential misunderstandings and oversights.

Page Categories

Page Information

2022-11-18T06:58:29.303877Z 2010-08-25T20:53:48Z Wormbo typo https://wiki.beyondunreal.com/Do...Until loop Attribution-NonCommercial-ShareAlike 3.0