Basic Pascal Tutorial/Chapter 3/REPEAT..UNTIL

From Lazarus wiki
Revision as of 22:35, 20 November 2020 by HowardPC (talk | contribs) (rewrite in more idiomatic English)
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

български (bg) English (en) français (fr) 日本語 (ja) 中文(中国大陆)‎ (zh_CN)

 ◄   ▲   ► 

REPEAT...UNTIL

The repeat .. until construct is termed a post-test loop, because the controlling condition is tested after each iteration of the loop.

It has the following syntax:

repeat
  statement1;
  // statement2;
  // further statements...
until BooleanExpression;

A repeat loop encloses its executed statements, which means they do not need to be further enclosed in a begin ... end block. Note that a repeat loop continues until its controlling Boolean expression is TRUE; whereas the while loop continues until its Boolean expression is FALSE.

Use a REPEAT loop when the looping statement(s) must execute at least once, whatever the initial value of the controlling Boolean condition.

 ◄   ▲   ►