Compound Statements

A compound statement is a sequence of other (simple or structured) statements to be executed in the order in which they are written. The compound statement is bracketed by the reserved words begin and end, and its constituent statements are separated by semicolons. For example:

begin

Z

:= X;

X

:= Y;

X

The last semicolon before end is optional. So we could have written this as

begin

Z

:= X;

X

:= Y;

Y

:= Z

end;

Compound statements are essential in contexts where Delphi syntax requires a single statement. In addition to program, function, and procedure blocks, they occur within other structured statements, such as conditionals or loops. For example:

begin

end;

You can write a compound statement that contains only a single constituent statement; like parentheses in a complex term, begin and end sometimes serve to disambiguate and to improve readability. You can also use an empty compound statement to create a block that does nothing:

begin end;

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Responses

  • carey
    What is a compound statement in delphi?
    8 years ago
  • longo
    What is delphi compound statements?
    8 years ago
  • ASKALU
    What is a compund statement delphi?
    8 years ago
  • Elisa
    How is a compound statement written?
    7 years ago

Post a comment