Your First Delphi 2007 Program
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:
Start Delphi by double-clicking on its Launch icon.
After Delphi has started, you will see the following Tool Palette
On the Tool Palette, double click on Console Application.
An editor window will appear. (See the Delphi 7 section for how to start a console application using the file menu).
On file menu, click on Save and save the program in a suitable folder as HelloWorld.dproj.
The program name should change in the editor window:
Delete the lines between begin and end then type the lines writeln('Hello World!');
followed by readln;
in their place.
Your first program should look like this:
- Carefully check that every character is correct. Especially check that the single quotes and the semi-colons are there.
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:
If it did not work, you will need to check again for errors, and correct them before clicking on the run icon again.
- Carefully check that every character is correct.
- Especially check that the single quotes and the semi-colons are there.
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).
- Press the Return key again, to make the program terminate.
- If you can think of anything we could have made more straightforward for you, then please let us know. If it did not work, then please tell us what went wrong.
New console program opened
Text denoted by single quotes
Text output to screen
If you want to, you can quit from Delphi by selecting menu item
Alternatively, you can move on to another topic.