Quick start manual

3-2
Delphi Language Guide
Program structure and syntax
The following example shows the project file for a program called Editor.
1 program Editor;
2
3 uses
4 QForms, {cross-platform Form}
5 REAbout in 'REAbout.pas' {AboutBox},
6 REMain in 'REMain.pas' {MainForm};
7
8 {$R *.res}
9
10 begin
11 Application.Title := 'Text Editor';
12 Application.CreateForm(TMainForm, MainForm);
13 Application.Run;
14 end.
Line 1 contains the program heading. The uses clause is on lines 3 through 6. Line 8 is
a compiler directive that links the project’s resource file into the program. Lines 10
through 14 contain the block of statements that are executed when the program runs.
Finally, the project file, like all source files, ends with a period.
This is, in fact, a fairly typical project file. Project files are usually short, since most of
a program’s logic resides in its unit files. Project files are generated and maintained
automatically, and it is seldom necessary to edit them manually.
The program heading
The program heading specifies the program’s name. It consists of the reserved word
program, followed by a valid identifier, followed by a semicolon. The identifier must
match the project file name. In the previous example, since the program is called
Editor, the project file should be called Editor.dpr.
In standard Pascal, a program heading can include parameters after the program
name:
program Calc(input, output);
Borland’s Delphi compiler ignores these parameters.
The program uses clause
The uses clause lists units that are incorporated into the program. These units may in
turn have uses clauses of their own. For more information about the uses clause, see
“Unit references and the uses clause” on page 3-5.
The block
The block contains a simple or structured statement that is executed when the
program runs. In most programs, the block consists of a compound statement—
bracketed between the reserved words begin and end—whose component