Your First Delphi 7 Program

Before doing this exercise you must first have Delphi installed on your PC.

We will use Delphi to create a simple program and run it.

The programming culture demands that the first program written in any language should output "Hello World!" to the screen. The steps to do this are as follows:

  1. Start Delphi by double-clicking on its Launch icon.
  2. On the menu bar click on File then New:

    The File-New menu

  3. Click on Other ...:

    The Other... menu

  4. Double click on Console Application.
    The editor window appears.
  5. On file menu, click on Save and save the program in a suitable folder as HelloWorld.dpr.

    The program name should change in the editor window:


    New console application

  6. Delete the line between begin and end then type the lines writeln('Hello World!'); followed by readln; in their place.

    Your first program should look like this:


    Hello World program

  7. Carefully check that every character is correct. Especially check that the single quotes and the semi-colons are there.
  8. The time has come to compile and run the program! Press the green triangle near the top left of the Delphi menu bar, OR press the F9 key.
    In case you were wondering, the file will be saved automatically, so you do not need to save it first.

    After a small delay, you should see a mainly black window appear with the output in the top left:


    Output of Hello World!

  9. If it did not work, you will need to check again for errors, and correct them before clicking on the run icon again.
    1. Carefully check that every character is correct.
    2. Especially check that the single quotes and the semi-colons are there.
  10. If it did work, you should notice:

    The green start icon has now changed to grey, indicating that the program is still running, and that consequently the icon is inactive.

    There is a blinking white cursor (a horizontal bar) on the black window, indicating that the program is awaiting input (due to the readln; statement).

  11. Press the Return key again, to make the program terminate.
Features introduced:
  • New console program opened

  • Program named

  • Text denoted by single quotes

  • Text output to screen

If you want to, you can quit from Delphi by selecting menu item File > Exit

Alternatively, you can move on to another topic.

Programming - a skill for life!

How to write and run Pascal programs in Delphi