Difference between revisions of "Repeat"

From Free Pascal wiki
Jump to navigationJump to search
(clean up syntax)
Line 1: Line 1:
 
{{Repeat}}
 
{{Repeat}}
  
This [[Reserved word|reserved word]] is used in a control construct that is similar to a [[While|<syntaxhighlight lang="pascal" enclose="none">while</syntaxhighlight>]] [[Do|<syntaxhighlight lang="pascal" enclose="none">do</syntaxhighlight>]] loop.
+
The [[Reserved word|reserved word]] {{HL|repeat}} is used as a [[loop instruction]] where the test occurs after the loop is executed. It is a control construct that is similar to a [[While|{{HL|while}}]]-[[Do|{{HL|do}}]] loop.
  
 
==Syntax==
 
==Syntax==
Line 11: Line 11:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
* <statement block>: A single [[Pascal]] [[statement]] or a [[Begin|<syntaxhighlight lang="pascal" enclose="none">begin</syntaxhighlight>]]-[[End|<syntaxhighlight lang="pascal" enclose="none">end</syntaxhighlight>]] statement block.
+
* <statement block>: One or more [[Pascal]] [[statement]]s. The {{HL|repeat}}-{{HL|until}} construct is a [[Block|block]] statement, so a [[Begin|{{HL|begin}}]]-[[End|{{HL|end}}]] statement block is not required.
 
* <condition>: [[expression|Expression]] that evaluates to a [[Boolean|<syntaxhighlight lang="pascal" enclose="none">boolean</syntaxhighlight>]] value.
 
* <condition>: [[expression|Expression]] that evaluates to a [[Boolean|<syntaxhighlight lang="pascal" enclose="none">boolean</syntaxhighlight>]] value.
  

Revision as of 00:10, 15 October 2020

Deutsch (de) English (en) suomi (fi) français (fr) русский (ru)

The reserved word repeat is used as a loop instruction where the test occurs after the loop is executed. It is a control construct that is similar to a while-do loop.

Syntax

  repeat
    <statement block>
  until <condition>;

Example

  x := 1;
  repeat
    DoSomethingHere(x);
    x := x + 1;
  until x = 10;



Keywords: begindoelseendforifrepeatthenuntilwhile