[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Compound                 0 or more Statements                  Statement Type

         begin
           <statement>;
           <statement>;
           ...
           <statement>
         end;

    A compound statement consists of the keyword BEGIN, followed by zero
    or more statements separated by semicolons, and ending with the
    keyword END. It can be used anywhere a single statement can be used.
    This is important, since Pascal syntax defines most control structures
    (conditional and iterative statements) as executing a single
    statement.

    For example, the WHILE loop is defined as follows:

         while <bool exp> do <statement>;

    In order to have the loop execute more than one statement, you
    substitute a compound statement for <statement>:

         while <bool exp> do begin <statement>; <statement>; ...
    <statement> end;

  -------------------------------- Example ---------------------------------

           Ch := 'a';
           while Ch <= 'z' do
             begin                  { Start of Compound statement }
               Writeln(Upcase(Ch),'-',Ch);
               Ch := Succ(Ch)
             end;                   { End of Compound statement }

           if Guess = True then
             begin                  { Start of Compound statement }
           MoveArm (Right);
           I := I + 2;
           TurnDown (I)
             end;                   { End of Compound statement }

See Also: statements iterative conditional begin end
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson