DelphiBasics
  Home  |  A brief history of Borland's Delphi
 Documents
 Tutorials

 Writing your first program
 Writing your second program
 Amending this program

 Delphi data types
   Numbers
   Text (strings and chars)
   Sets and enumerations
   Arrays
   Records

 Programming logic
   Looping
   SubRoutines
   Exception handling

 Dates and times

 Files

 Pointers

 Printing text and graphics

 Object Orientation basics
   Memory leaks!
   Inheritance
   Abstraction
   Interfaces
   An example class

 References

 Standard components

 Articles

 A brief history of Delphi

 Usability : file handling

 Usability : reference books

 Author links

  A brief history of Borland's Delphi
PascalDifferent types of application
Delphi allows you to create GUI (Graphical User Interface) or Console (text-only) applications (programs) along with many other types. We will concern ourselves here with the common, modern, GUI application.
 
Delphi does a lot of work for us - the programmer simply uses the mouse to click, drag, size and position graphical parts to build each screen of the application.
 
Each part (or element) can be passive (displaying text or graphics), or active (responding to a user mouse or keyboard action).
 
This is best illustrated with a very simple program.
 

Creating a simple 'Hello World' program
When you first run Delphi, it will prepare on screen a new graphical application. This comprises a number of windows, including the menu bar, a code editor, and the first screen (form) of our program. Do not worry about the editor window at the moment.
 
The form should look something like this :
 

 
We have shown the form reduced in size for convenience here, but you will find it larger on your computer. It is a blank form, onto which we can add various controls and information. The menu window has a row of graphical items that you can add to the form. They are in tabbed groups : Standard, Additional, Win32 and so on.
 
We will select the simplest from the Standard collection. Click on the A image to select a Label. This A will then show as selected:
 

 
Having selected a graphical element, we then mark out on the form where we want to place the element. This is done by clicking and dragging. This gives us our first form element:
 

 

Changing graphical element properties
Notice that the graphical element contains the text Label1 as well as resize corners. The text is called the Caption, and will appear when we run the application. This Caption is called a Property of the label. The label has many other properties such as height and width, but for now, we are only concerned with the caption.
 
Let us blank out the caption. We do this in the window called the Object Inspector (available under the View menu item if not already present):
 

 

Adding an active screen element
If we now return to the Standard graphical element collection, and select a button, shown as a very small button with OK on it, we can add this to the form as well:
 

 

 
We now have a label and a button on the form. But the button will do nothing when pressed until we tell Delphi what we want it to do.
 
So we must set an action, called an Event, for the button. The main event for a button is a Click. This can be activated simply by double clicking the button on the form.
 
This will automatically add an event called OnClick for the button, and add a related event handler in the program code:
 

 
This 'skeleton' code will not do anything as it stands. We must add some code. Code that we add will run when the button is clicked. So let us change the label caption when the button is pressed.
 
As we type, Delphi helps us with a list of possible options for the item we are working on. In our instance, we are setting a Label caption:
 

 
Here you see that Delphi has listed all appropriate actions that start with ca. If we press Enter, Delphi will complete the currently selected item in the list. We assign a text value 'Hello World' to the caption property. Note that we terminate this line of code with a ; - all Delphi code statements end with this indicator. It allows us to write a command spread across multiple lines - telling Delphi when we have finished the command.
 

 
And we have now finished our very simple action - we will set the label to 'Hello World' when the button is pressed.
 

Running our first program
To run the program, we can click on the Green triangle (like a Video play button), or press F9. When the program runs it looks like this:
 

 
When we click on the button, we get:
 

 
and our program has set the Label text as we requested.
 
Note that the program is still running. We can click as many times as we like with the same outcome. Only when we close the program by clicking on the top right X will it terminate.
 

Looking at the code that Delphi generated
Whilst we have only typed one line of code, Delphi has typed many for us. Let us first look at the main program code. Notice that we have added comments (in green, starting with the // comment identifier). These are ignored by the Delphi compiler, but help the coder understand the code. You can click on any word marked in blue to see reference information for that word:
 
 unit Unit1;
 
 interface
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, StdCtrls;
 
 type
   TForm1 = class(TForm)
     Label1: TLabel;     // The label we have added
     Button1: TButton;   // The button we have added
     procedure Button1Click(Sender: TObject);
   private
     { Private declarations }
   public
     { Public declarations }
   end;
 
 var
   Form1: TForm1;
 
 implementation
 
 {$R *.dfm}
 
 // The button action we have added
 procedure TForm1.Button1Click(Sender: TObject);
 begin
   Label1.Caption := 'Hello World';   // Label changed when button pressed
 end;
 
 end.

This code isPascalDifferent types of application
 
Delphi allows you to create GUI (Graphical User Interface) or Console (text-only) applications (programs) along with many other types. We will concern ourselves here with the common, modern, GUI application.
 
Delphi does a lot of work for us - the programmer simply uses the mouse to click, drag, size and position graphical parts to build each screen of the application.
 
Each part (or element) can be passive (displaying text or graphics), or active (responding to a user mouse or keyboard action).
 
This is best illustrated with a very simple program.
 

Creating a simple 'Hello World' program
When you first run Delphi, it will prepare on screen a new graphical application. This comprises a number of windows, including the menu bar, a code editor, and the first screen (form) of our program. Do not worry about the editor window at the moment.
 
The form should look something like this :
 

 
We have shown the form reduced in size for convenience here, but you will find it larger on your computer. It is a blank form, onto which we can add various controls and information. The menu window has a row of graphical items that you can add to the form. They are in tabbed groups : Standard, Additional, Win32 and so on.
 
We will select the simplest from the Standard collection. Click on the A image to select a Label. This A will then show as selected:
 

 
Having selected a graphical element, we then mark out on the form where we want to place the element. This is done by clicking and dragging. This gives us our first form element:
 

 

Changing graphical element properties
Notice that the graphical element contains the text Label1 as well as resize corners. The text is called the Caption, and will appear when we run the application. This Caption is called a Property of the label. The label has many other properties such as height and width, but for now, we are only concerned with the caption.
 
Let us blank out the caption. We do this in the window called the Object Inspector (available under the View menu item if not already present):
 

 

Adding an active screen element
If we now return to the Standard graphical element collection, and select a button, shown as a very small button with OK on it, we can add this to the form as well:
 

 

 
We now have a label and a button on the form. But the button will do nothing when pressed until we tell Delphi what we want it to do.
 
So we must set an action, called an Event, for the button. The main event for a button is a Click. This can be activated simply by double clicking the button on the form.
 
This will automatically add an event called OnClick for the button, and add a related event handler in the program code:
 

 
This 'skeleton' code will not do anything as it stands. We must add some code. Code that we add will run when the button is clicked. So let us change the label caption when the button is pressed.
 
As we type, Delphi helps us with a list of possible options for the item we are working on. In our instance, we are setting a Label caption:
 

 
Here you see that Delphi has listed all appropriate actions that start with ca. If we press Enter, Delphi will complete the currently selected item in the list. We assign a text value 'Hello World' to the caption property. Note that we terminate this line of code with a ; - all Delphi code statements end with this indicator. It allows us to write a command spread across multiple lines - telling Delphi when we have finished the command.
 

 
And we have now finished our very simple action - we will set the label to 'Hello World' when the button is pressed.
 

Running our first program
To run the program, we can click on the Green triangle (like a Video play button), or press F9. When the program runs it looks like this:
 

 
When we click on the button, we get:
 

 
and our program has set the Label text as we requested.
 
Note that the program is still running. We can click as many times as we like with the same outcome. Only when we close the program by clicking on the top right X will it terminate.
 

Looking at the code that Delphi generated
Whilst we have only typed one line of code, Delphi has typed many for us. Let us first look at the main program code. Notice that we have added comments (in green, starting with the // comment identifier). These are ignored by the Delphi compiler, but help the coder understand the code. You can click on any word marked in blue to see reference information for that word:
 
 unit Unit1;
 
 interface
 
 uses
   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
   Dialogs, StdCtrls;
 
 type
   TForm1 = class(TForm)
     Label1: TLabel;     // The label we have added
     Button1: TButton;   // The button we have added
     procedure Button1Click(Sender: TObject);
   private
     { Private declarations }
   public
     { Public declarations }
   end;
 
 var
   Form1: TForm1;
 
 implementation
 
 {$R *.dfm}
 
 // The button action we have added
 procedure TForm1.Button1Click(Sender: TObject);
 begin
   Label1.Caption := 'Hello World';   // Label changed when button pressed
 end;
 
 end.

This code is called a Unit and is a Delphi module - one chunk of code. If you save this code, it will save in a file called Unit1.pas - a Pascal file.
 
The unit comprises two main parts - the interface section, which tells what the unit does. And an implementation section that holds the code that implements the interface. Click on the unit keyword in the code to learn more.
 

Learning more ...
If you want to learn more, then try the following:
 
1.Right click on the form, and select the View as text item from the drop down list. This will show the form, label and button properties.
 
2.View the main program file by selecting menu item Project/View source. This will show the code that Delphi generated to kick start your program. It includes a reference to Unit1.pas and your form, and starts your program running.
 
Delphi uses the language Pascal, a third generation structured language. It is what is called a highly typed language. This promotes a clean, consistent programming style, and, importantly, results in more reliable applications. Pascal has a considerable heritage:
 
Beginnings
Pascal appeared relatively late in the history of programming languages. It probably benefited from this, learning from Fortran, Cobol and IBM's PL/1 that appeared in the early 1960's. Niklaus Wirth is claimed to have started developing Pascal in 1968, with a first implementation appearing on a CDC 6000 series computer in 1970. It took its roots from the Algol-60 and Algol-W line of languages. These languages were designed to avoid the errors that could beset FØRTRAN and COBOL.
 
Curiously enough, the C language did not appear until 1972. C sought to serve quite different needs to Pascal. C was designed as a high level language that still provided the low level access that assembly languages gave. Pascal was designed for the development of structured, maintainable applications.
 
The 1970's
In 1975, Wirth teamed up with Jensen to produce the definitive Pascal reference book "Pascal User Manual and Report". Wirth moved on from Pascal in 1977 to work on Modula - the successor to Pascal.
 
The 1980's
In 1982 ISO Pascal appears. Around this time, a product called Compas Pascal was made by a young Danish man called Anders Hejlsberg (yes, the mastermind of C#). This product resembled the later Turbo Pascal in the blazing speed of compilation and execution. Later it was remade and renamed to PolyPascal by a company called PolyData A/S, primarily owned by Anders Hejlsberg and finally it was sold to Borland, where it appeared as Turbo Pascal in November 1983 in a blaze of publicity. Turbo Pascal reached release 4 by 1987. Turbo Pascal excelled on speed of compilation and execution, leaving the competition in its wake.
 
CodeGear Delphi 2009

From Turbo Pascal to Delphi
Delphi, Borland's powerful Windows? and Linux? programming development tool first appeared in 1995. It derived from the Turbo Pascal? product line.
 
As the opposition took heed of Turbo Pascal, and caught up, Borland took a gamble on an Object Oriented version, mostly based on the Pascal object orientation extensions. The risk paid off, with a lot of the success due to the thought underlying the design of the IDE (Integrated Development Environment), and the retention of fast compilation and execution.
 
This first version of Delphi was somewhat limited when compared to today's heavyweights, but succeeded on the strength of what it did do. And speed was certainly a key factor. Delphi went through rapid changes through the 1990's.
 

Delphi for Microsoft .Net
From that first version, Delphi went through 7 further iterations before Borland decided to embrace the competition in the form of the Microsoft? .Net architecture with the stepping stone Delphi 8 and then fully with Delphi 2005 and 2006. Delphi however still remains, in the opinion of the author, the best development tool for stand alone Windows and Linux applications. Pascal is a cleaner and much more disciplined language than Basic, and adapted much better to Object Orientation than Basic.
 

New directions
Delphi is now provided by : Embarcadero.
 

And there are free, Open Source Implementations of Object Pascal by the name of 'Free Pascal' and of Delphi by the name of 'Lazarus'.
 


 


 

The above mentioned software is available for purchase at their site via merchant services similar to the ones found through Flagship merchant services and similar companies. called a Unit and is a Delphi module - one chunk of code. If you save this code, it will save in a file called Unit1.pas - a Pascal file.
 
The unit comprises two main parts - the interface section, which tells what the unit does. And an implementation section that holds the code that implements the interface. Click on the unit keyword in the code to learn more.
 

Learning more ...
If you want to learn more, then try the following:
 
1.Right click on the form, and select the View as text item from the drop down list. This will show the form, label and button properties.
 
2.View the main program file by selecting menu item Project/View source. This will show the code that Delphi generated to kick start your program. It includes a reference to Unit1.pas and your form, and starts your program running.
 
Delphi uses the language Pascal, a third generation structured language. It is what is called a highly typed language. This promotes a clean, consistent programming style, and, importantly, results in more reliable applications. Pascal has a considerable heritage:
 
Beginnings
Pascal appeared relatively late in the history of programming languages. It probably benefited from this, learning from Fortran, Cobol and IBM's PL/1 that appeared in the early 1960's. Niklaus Wirth is claimed to have started developing Pascal in 1968, with a first implementation appearing on a CDC 6000 series computer in 1970. It took its roots from the Algol-60 and Algol-W line of languages. These languages were designed to avoid the errors that could beset FØRTRAN and COBOL.
 
Curiously enough, the C language did not appear until 1972. C sought to serve quite different needs to Pascal. C was designed as a high level language that still provided the low level access that assembly languages gave. Pascal was designed for the development of structured, maintainable applications.
 
The 1970's
In 1975, Wirth teamed up with Jensen to produce the definitive Pascal reference book "Pascal User Manual and Report". Wirth moved on from Pascal in 1977 to work on Modula - the successor to Pascal.
 
The 1980's
In 1982 ISO Pascal appears. Around this time, a product called Compas Pascal was made by a young Danish man called Anders Hejlsberg (yes, the mastermind of C#). This product resembled the later Turbo Pascal in the blazing speed of compilation and execution. Later it was remade and renamed to PolyPascal by a company called PolyData A/S, primarily owned by Anders Hejlsberg and finally it was sold to Borland, where it appeared as Turbo Pascal in November 1983 in a blaze of publicity. Turbo Pascal reached release 4 by 1987. Turbo Pascal excelled on speed of compilation and execution, leaving the competition in its wake.
 
CodeGear Delphi 2009

From Turbo Pascal to Delphi
Delphi, Borland's powerful Windows? and Linux? programming development tool first appeared in 1995. It derived from the Turbo Pascal? product line.
 
As the opposition took heed of Turbo Pascal, and caught up, Borland took a gamble on an Object Oriented version, mostly based on the Pascal object orientation extensions. The risk paid off, with a lot of the success due to the thought underlying the design of the IDE (Integrated Development Environment), and the retention of fast compilation and execution.
 
This first version of Delphi was somewhat limited when compared to today's heavyweights, but succeeded on the strength of what it did do. And speed was certainly a key factor. Delphi went through rapid changes through the 1990's.
 

Delphi for Microsoft .Net
From that first version, Delphi went through 7 further iterations before Borland decided to embrace the competition in the form of the Microsoft? .Net architecture with the stepping stone Delphi 8 and then fully with Delphi 2005 and 2006. Delphi however still remains, in the opinion of the author, the best development tool for stand alone Windows and Linux applications. Pascal is a cleaner and much more disciplined language than Basic, and adapted much better to Object Orientation than Basic.
 

New directions
Delphi is now provided by : Embarcadero.
 

And there are free, Open Source Implementations of Object Pascal by the name of 'Free Pascal' and of Delphi by the name of 'Lazarus'.
 


 
 
 

Delphi Basics © Neil Moffatt All rights reserved.  |  Home Page