VMS Help
PASCAL, Statements, REPEAT

 *Conan The Librarian (sorry for the slow response - running on an old VAX)

  The REPEAT statement is a looping statement and executes one  or
  more statements until a specified condition is true.

  Syntax:

     REPEAT
        {statement};...
     UNTIL expression

  The 'statement' is any Compaq Pascal statement.

  The 'expression' is any Boolean expression.

  Compaq  Pascal  always  executes  a  REPEAT  statement  for  one
  iteration; iterations continue as long as the Boolean expression
  is FALSE.  When specifying more than one statement as  the  loop
  body  to  a REPEAT statement, do not enclose the statements with
  the BEGIN and END reserved words; multiple statements are  legal
  in the REPEAT loop body.

  1 - Examples

     REPEAT
        READ (x);
        IF (x IN ['0'..'9'])
        THEN
           BEGIN
           Digit_count := Digit_count + 1;
           Digit_sum := Digit_sum + ORD (x) - ORD ('0');
           END
        ELSE
           Char_count := Char_count + 1;
     UNTIL EOLN (INPUT);

  Assume that the variable 'x' is of type CHAR and  the  variables
  'Digit_count',  'Digit_sum',  and  'Char_count' denote integers.
  The example reads a character (x).  If the value  of  'x'  is  a
  digit,  the count of digits is incremented by one and the sum of
  digits is increased by the value of 'x', as computed by the  ORD
  function.   If  the  value  of  'x' is not a digit, the variable
  'Char_count' is incremented by one.  The REPEAT  loop  continues
  processing characters until it reaches an end-of-line condition.
  Close     HLB-list     TLB-list     Help  

[legal] [privacy] [GNU] [policy] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.