Name
Uses Keyword
Syntax
usesUnit name, ...; usesUnit nameinFile name, ...
Description
The uses keyword lists the names of units that are
imported into the surrounding unit, program, or library. The
uses declaration is optional, but if you use it,
it must be the first declaration in a program, library, or in the
interface and implementation sections of a
unit.
Tips and Tricks
In a program or library, the syntax can follow the second form, where the
File nameis a string literal that specifies the path to the file that contains the unit’s source code. The compiler uses the path information to locate the file for compiling it, and the IDE uses the path to manage the project.Any changes made to a unit’s interface section may cause all dependent units to be recompiled. A dependent unit is recompiled if it uses any of the declarations that changed in the original unit’s interface section. In a large project, you can save yourself some recompilation time by using units in the implementation section as much as possible.
The symbols a unit exports in its interface section are available to any other unit that uses the first unit. Delphi searches the used units in order from last to first. Thus, units listed later in a
usesdeclaration take precedence over units listed earlier. If you need to use a symbol from a unit listed earlier, you can qualify the symbol name with the unit name followed by a dot (.).
Example
uses SysUtils, Windows; // Windows and SysUtils both define DeleteFile. Because ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access