SmartPascal
Implementation
Keyword
Starts the implementation (code) section of a Unit
  Unit UnitName;
  Interface
    Declarations...
  Implementation
    Declarations...
  End;
Description
The Implementation keyword starts the active code section of a unit - where the interface declarations are implemented.
 
A Delphi Unit is seen externally by its Interface declarations. Internally, these are implemented in the Implementation section. Only chnages to the Interface will cause a recompile of external units.
 
Within the Implementation section, the functions and procedures defined in the Interface section are coded. This section may have its own functions, procedures and data over and above that defined by the Interface. These are in effect private to the unit.
 
It may also have its own Uses statement, where Units are defined that are only used by the implementation. They are specific to the implementation, and external users of the Unit need not know about them.
Related commands
Const Starts the definition of fixed data values
Function Defines a subroutine that returns a value
Interface Used for Unit external definitions, and as a Class skeleton
Procedure Defines a subroutine that does not return a value
Type Defines a new category of variable or process
Unit Defines the start of a unit file - a Delphi module
Uses Declares a list of Units to be imported
Var Starts the definition of a section of data variables
 
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

uses
  Forms;

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

var
  Form1: TForm1;

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

uses             // Private units
  Dialogs;

var              // Private variables
  msg : string;

const            // Private constants
  MSG_TEXT = 'Hello World';

// A private routine - not predefined in the Interface section
procedure SayHello;
begin
  // Say hello to the World
  msg := MSG_TEXT;
  ShowMessage(msg);
end;

// A routine pre-defined in the Interface section
procedure TForm1.FormCreate(Sender: TObject);
begin
  // Say hello
  SayHello;
end;

end.
   Hello World