Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

USES clause - Interface vs. Implementation

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I am developing a Delphi application. As a rule I have always listed the self-developed units (and the like) in the 'implementation' section of the form (or unit) - for instance :

unit Form1
..
interface
uses SysUtils, DB, etc...
..
implementation
uses SKForm1, SKUnit1, SKGlobal1, etc...

Due to the fact that I have a class (TCustomer) within one of these listed units (SKGlobal1) and am wanting to pass an instance of it into one of the procedures within 'Form1' I now find myself having to place the reference in the 'interface' part (otherwise the compiler halts due to the fact that the TCustomer class is not seen). The layout then becomes something like :

unit Form1
..
interface
uses SysUtils, DB, SKGlobal1, etc...
..
implementation
uses SKForm1, SKUnit1, etc...

What difference does the placing of the reference to this unit make (placing the reference in the 'interface' section rather than the 'implementation') ?

Thanks in advance.
Steve
 
Steve,

It looks like you've discovered the difference on your own!!

You should put any unit that is required for your interface declaration in the interface uses clause, and all other units that are only required for implementation in the implementation uses clause. Regardless of whether they are your own or standard Delphi units.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top