Quick start manual

3-6
Delphi Language Guide
Unit references and the uses clause
If such an explicit reference appears in the project file, other source files can refer to
the unit with a simple uses clause that does not need to match case:
uses Myunit;
For more information about the placement and content of the uses clause, see
“Multiple and indirect unit references” on page 3-7 and “Circular unit references” on
page 3-8.
The syntax of a uses clause
A uses clause consists of the reserved word uses, followed by one or more comma-
delimited unit names, followed by a semicolon. Examples:
uses Forms, Main;
uses
Forms,
Main;
uses Windows, Messages, SysUtils, Strings, Classes, Unit2, MyUnit;
uses SysUtils, Types, Classes, QGraphics, QControls, QForms, QDialogs;
In the uses clause of a program or library, any unit name may be followed by the
reserved word in and the name of a source file, with or without a directory path, in
single quotation marks; directory paths can be absolute or relative. Examples:
uses {This example is Windows-specific}
Windows,
Messages,
SysUtils,
Strings in 'C:\Classes\Strings.pas', Classes;
uses {this is a Linux example}
QForms,
Main,
Extra in '../extra/extra.pas';
Include in ... after a unit name when you need to specify the unit’s source file. Since
the IDE expects unit names to match the names of the source files in which they
reside, there is usually no reason to do this. Using in is necessary only when the
location of the source file is unclear, for example when
You have used a source file that is in a different directory from the project file, and
that directory is not in the compiler’s search path.
Different directories in the compiler’s search path have identically named units.
You are compiling a console application from the command line, and you have
named a unit with an identifier that doesn’t match the name of its source file.
The compiler also relies on the in ... construction to determine which units are part of
a project. Only units that appear in a project (.dpr) file’s uses clause followed by in
and a file name are considered to be part of the project; other units in the uses clause
are used by the project without belonging to it. This distinction has no effect on
compilation, but it affects IDE tools like the Project Manager and Project Browser.