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;


Forms, Main;

uses Windows, Messages, SysUtils, Strings, Classes, Unit2, MyUnit;

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:


Windows, Messages, SysUtils,

Strings in 'C:\Classes\Strings.pas', Classes;

Use the keyword 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.

In the uses clause of a unit, you cannot use in to tell the compiler where to find a source file. Every unit must be in the compiler's search path. Moreover, unit names must match the names of their source files.

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

Post a comment