Declares a list of Units to be imported
1 keyword Uses(Uses Unit1 {Unit2, ...};
2 Uses Unit1 in FileName1 {Unit2, ...};
The Uses keyword defines a list of one or more units that are used by the current unit, program or library.
Each unit is effectively imported - all public or published routines and data in each unit is made available.
For example, including SysUtils makes available a lot of data manipulation routines, such as IntToStr.
The order of the units in the list is important. Those later in the list take precedence over the earlier ones. In the rare situation where the same routine or data is defined in two or more units, you can force Delphi to use the desired unit by prefixing that unit name to the routine or data name.
For Units, the Uses may be defined in the Interface and Implementation sections. It is cleaner and may save recompilations if you put units used in the implementation section if they are only used there.
Version 1 is the standard form - it lets Delphi find the units.
Version 2 defines the FileName, including path, where the unit resides. This is only applicable to programs and libraries.
System is included by default - there is no need to explictly include it.
Related commands
ImplementationStarts the implementation (code) section of a Unit
InterfaceUsed for Unit external definitions, and as a Class skeleton
UnitDefines the start of a unit file - a Delphi module
 Download this web site as a Windows program.

Example code : A simple example
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.

unit Unit1;

interface         // Defines the external view of this unit


  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);

  Form1: TForm1;

Implementation   // Implements the Interface of this unit
{$R *.dfm}       // Include form definitions

Uses             // Private units
  Dialogs, SysUtils;

// A private routine - not predefined in the Interface section
procedure SayNumber(number : Integer);
  // Say a number as a string
  // Note that we are very specific about the IntToStr routine :
  // we are making it unambiguous that it is the SysUtils
  // version that we are using.
  ShowMessage('Number = '+SysUtils.IntToStr(number));

// A routine pre-defined in the Interface section
procedure TForm1.FormCreate(Sender: TObject);
  // Display a number

  Number = 123
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page