Quick start manual

2-2
Delphi Language Guide
Program organization
Delphi source files
The compiler expects to find Delphi source code in files of three kinds:
unit source files (which end with the .pas extension)
project files (which end with the .dpr extension)
package source files (which end with the .dpk extension)
Unit source files typically contain most of the code in an application. Each
application has a single project file and several unit files; the project file—which
corresponds to the “main” program file in traditional Pascal—organizes the unit files
into an application. Borland development tools automatically maintain a project file
for each application.
If you are compiling a program from the command line, you can put all your source
code into unit (.pas) files. If you use the IDE to build your application, it will produce
a project (.dpr) file.
Package source files are similar to project files, but they are used to construct special
dynamically linkable libraries called packages. For more information about packages,
see Chapter 9, “Libraries and packages”.
Other files used to build applications
In addition to source-code modules, Borland products use several non-Pascal files to
build applications. These files are maintained automatically and include
form files, which end with the .dfm (Windows-specific) or .xfm (Cross-platform)
extension,
resource files, which end with the .res extension, and
project options files, which end with .dof (Windows) or .kof (Linux) extension.
A form file contains the description of the properties of the form and the components
it owns. This description may be present in text form (a format very suitable for
version control) or in a compressed binary format. Each form file represents a single
form, which usually corresponds to a window or dialog box in an application. The
IDE allows you to view and edit form files as text, and to save form files as either text
or binary. Although the default behavior is to save form files as text, they are usually
not edited manually; it is more common to use Borland’s visual design tools for this
purpose. Each project has at least one form, and each form has an associated unit
(.pas) file that, by default, has the same name as the form file.
In addition to form files, each project uses a resource (.res) file to hold the bitmap for
the application’s icon. By default, this file has the same name as the project (.dpr) file.
To change an application’s icon, use the Project Options dialog.
A project options (.dof or .kof) file contains compiler and linker settings, search path
information, version information, and so forth. Each project has an associated project
options file with the same name as the project (.dpr) file. Usually, the options in this
file are set from Project Options dialog.