Unit References and the Uses Clause

A uses clause lists units used by the program, library, or unit in which the clause appears. A uses clause can occur in

  • the project file for a program, or library
  • the interface section of a unit
  • the implementation section of a unit

Most project files contain a uses clause, as do the interface sections of most units. The implementation section of a unit can contain its own uses clause as well.

The System unit and the Sysinit unit are used automatically by every application and cannot be listed explicitly in the uses clause. (System implements routines for file I/O, string handling, floating point operations, dynamic memory allocation, and so forth.) Other standard library units, such as SysUtils, must be explicitly included in the uses clause. In most cases, all necessary units are placed in the uses clause by the IDE, as you add and remove units from your project.

In unit declarations and uses clauses, unit names must match the file names in case. In other contexts (such as qualified identifiers), unit names are case insensitive. To avoid problems with unit references, refer to the unit source file explicitly:

uses MyUnit in "myunit.pas";

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;

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