Quick start manual
Programs and units
3-1
Chapter
3
Chapter3
Programs and units
A program is constructed from source-code modules called units. Each unit is stored
in its own file and compiled separately; compiled units are linked to create an
application. Units allow you to
• divide large programs into modules that can be edited separately.
• create libraries that you can share among programs.
• distribute libraries to other developers without making the source code available.
In traditional Pascal programming, all source code, including the main program, is
stored in .pas files. Borland tools use a project (.dpr) file to store the “main” program,
while most other source code resides in unit (.pas) files. Each application—or
project—consists of a single project file and one or more unit files. (Strictly speaking,
you needn’t explicitly use any units in a project, but all programs automatically use
the System unit and the SysInit unit.) To build a project, the compiler needs either a
source file or a compiled unit file for each unit.
Program structure and syntax
A program contains
•a program heading,
•a uses clause (optional), and
• a block of declarations and statements.
The program heading specifies a name for the program. The uses clause lists units
used by the program. The block contains declarations and statements that are
executed when the program runs. The IDE expects to find these three elements in a
single project (.dpr) file.