Difference between revisions of "Basic Pascal Tutorial/Chapter 3/REPEAT..UNTIL"

From Lazarus wiki
Jump to navigationJump to search
Line 16: Line 16:
 
|[[WHILE..DO|previous]]   
 
|[[WHILE..DO|previous]]   
 
|[[Contents|contents]]  
 
|[[Contents|contents]]  
|[[Programming_Assignment_3|next]]
+
|[[FOR..IN|next]]
 
|}
 
|}

Revision as of 16:00, 5 January 2010

REPEAT..UNTIL (author: Tao Yue, state: unchanged)

The posttest loop has the following format: <delphi> repeat

 statement1;
 statement2

until BooleanExpression; </delphi>

In a repeat loop, compound statements are built-in -- you don't need to use begin-end. Also, the loop continues until the Boolean expression is TRUE, whereas the while loop continues until the Boolean expression is FALSE.

This loop is called a posttest loop because the condition is tested after the body of the loop executes. The REPEAT loop is useful when you want the loop to execute at least once, no matter what the starting value of the Boolean expression is.

previous contents next