Difference between revisions of "Basic Pascal Tutorial/Chapter 3/REPEAT..UNTIL"
From Lazarus wiki
Jump to navigationJump to search (New page: REPEAT..UNTIL The posttest loop has the following format: <font color="#006699"><strong>repeat</strong></font> statement1<font color="#000000"><strong>;</strong></font> statement2 ...) |
|||
Line 6: | Line 6: | ||
statement2 | statement2 | ||
<font color="#006699"><strong>until</strong></font> BooleanExpression<font color="#000000"><strong>;</strong></font> | <font color="#006699"><strong>until</strong></font> BooleanExpression<font color="#000000"><strong>;</strong></font> | ||
− | |||
− | |||
− | |||
− | |||
In a <tt>repeat</tt> loop, compound statements are built-in -- you don't need to use begin-end. Also, the loop continues until the Boolean expression is <tt>TRUE</tt>, whereas the <tt>while</tt> loop continues until the Boolean expression is <tt>FALSE</tt>. | In a <tt>repeat</tt> loop, compound statements are built-in -- you don't need to use begin-end. Also, the loop continues until the Boolean expression is <tt>TRUE</tt>, whereas the <tt>while</tt> loop continues until the Boolean expression is <tt>FALSE</tt>. |
Revision as of 13:05, 21 November 2007
REPEAT..UNTIL
The posttest loop has the following format:
repeat statement1; statement2 until BooleanExpression;
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 |