Name

Contains Directive

Syntax

package Name;
contains Unit, Unit in FileName;
...

Description

The contains directive heads a list of unit names that make up a package. The unit names are separated by commas, and each unit name can appear as just the name or the name followed by the name of the unit’s file as a string.

Tips and Tricks

  • All the units that are used by the units contained in a package must reside in the package itself or in one of the required packages. Delphi must know where to find every referenced unit so it can compile the package.

  • You cannot list the same unit more than once, and all the units that a package contains must not be in any of the required packages. This rule prevents a unit from being included more than once in a project.

  • Usually, you will use Delphi’s package editor to add units to a package or remove units from a package. You can edit the package source manually, but doing so does not update the package editor. Close and reopen the project or project group to force Delphi to read the new package source file.

  • Delphi’s IDE does not always treat a package as a project. If you have difficulties with the IDE, try creating a new project group, then add the package to the project group.

See Also

Package Keyword, Requires Directive, Unit Keyword, Uses Keyword

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.