HP Pascal/iX Reference Manual (31502-90022)

6: 3
Example
PROCEDURE check_min;
BEGIN { This }
IF min > max THEN { compound }
BEGIN { Compound } { statement }
writeln('Min is wrong.'); { statement is } { is }
min := 0; { part of IF } { the }
END; { statement. } { procedure's }
END; { body. }
. . .
BEGIN { Nested compound statements }
IF part_to_start=part_1 THEN
BEGIN { for logically grouping statements. }
start_part_1;
finish_part_1;
{ empty statement here }
END
ELSE
BEGIN
start_part_2;
finish_part_2;
END;
END;
...
BEGIN .. END
BEGIN and END are reserved words that signify the beginning and ending of
a compound statement or block. BEGIN indicates to the compiler that a
compound statement or block has started, whereas END indicates that a
compound statement or block has terminated.
Syntax
Example
PROGRAM show_begin_end(input, output);
VAR
running : Boolean;
i, j : integer;
BEGIN {begin of program block}
i := 0;
j := 1;
running := true;
writeln('See Dick run.');
writeln('Run Dick run.');
IF running then
BEGIN {begin of compound statement}
i := i + 1;
j := j - 1;
END; {end of compound statement}
END. {end of program block}
Output:
See Dick run.
Run Dick run.