Crash Course Delphi, part 1: Compiling a project

Turbo Start

Delphi combines the user-friendlyness of Visual Basic with the precise control and speed of C++. Without lots of "real" programming, you can develop very efficient and fast Windows applications.

Delphi is a RAD tool, Rapid Application Development. It reduces the complicated task of programming Windows applications to the handling of "objects" in a visual environment.

Typing of source code is limited to a strict minimum. As a result, you can fully concentrate on what the program should do: this is top-down programming at its highest level, designing a nice Windows GUI interface becomes a breeze. You don't have to "program" any standard Windows elements, just a few mouse clicks and there's your fully functional listbox, file dialog box, or even a full fledged database grid.

With Delphi, debugging is limited to the program lines that you entered yourself, because all the ready-made modules that you use are tested and ready-to-go.

Compared to the limited possibilities of Visual Basic or the complexity of C++, Delphi is really refreshing. Once you've used Delphi, you'll be fascinated by its sheer development speed.

For starters, a few general things about this Delphi Tutorial:
Will it work with Delphi 2007 or Delphi 6 or ...? Sure! All the lessons are 100% compatible with Delphi XE down to Delphi 4.
VCL, IDE, OOP...? In order to get you up to speed quickly on acronyms, in one of the first lessons of our second tutorial, we'll make the program Acron.
For those who are too impatient: the exe-file of Acron can be found in the Downloads section as ACRONX.ZIP. Also download ACRODAT4.ZIP: it contains the list of acronyms. This list will grow. Every new and enhanced version will get a higher number (yep, the next one will be ACRODAT5.ZIP, and afterwards..., and so on).
By the way (BTW), D7 means Delphi 7, so D2007 is...? Correct. For "the 32-bits versions of Delphi, D4 up to the latest..." I came up with the very original D4+.
Run before you can walk? Yes, that's possible with Delphi. No need to start studying the old Turbo Pascal, no need to know anything about OOP (Object Oriented Programming). Just learn as you practice, and we'll fill in the gaps later on.
So, no traditional "Hello, World" proggie in my courses. We'll start immediately with a real application. After all, it's R.A.D time -- let's go!


  1. If you haven't done so already, create a new folder (directory, as they said in the old days) \DelphiLa on your harddisk (C: or D: or ...). Next, download the first series of lessons from the Downloads section and unzip it to this directory.
  2. If you haven't done so already, create directory EuroCCEN "under" \DelphiLa. Next, download (source code for the first finished project) from the Downloads section and unzip it to this directory. When checking with Windows Explorer, you'll see euroccen.dpr, euroform.dfm and euroform.pas.
  3. Now start the introduction lesson: in Windows Explorer, doubleclick on index.html (in folder \DelphiLa). You're all set to follow the first lesson offline!

Euro Currency Convertor: compilation

Our very first project is a Euro Currency Convertor. The English ready-to-go version is called EuroCCEN. You compile and test it as follows:
  1. Doubleclick in Windows Explorer (or in My Computer) on euroccen.dpr: Delphi starts and it opens the project "euroccen".
  2. Open Delphi's Run menu and click Run.

    RUN menu
  3. Your project is compiled and linked: the result is euroccen.exe. Immediately after that, the program euroccen.exe is launched. All this happens so fast, that you probably even didn't notice that your source code was compiled into an executable program!

  4. Enter a new valid number in the EDIT-box, for example: 25. Click on the button with the caption "equals". In the right frame, you should see the corresponding amounts in the other European currencies.
  5. Click on one of the radiobuttons for the starting currency, for example BEF/LUF. Note that the corresponding label for Belgian en Luxemburg frank becomes invisible. That's because I found it quite silly if the program should show that 25 BEF = 25 BEF... On top of that, this trick gives a clear visual feedback as to the starting currency.

  6. Click the radiobutton 4 for the number of decimals. All converted numbers now are shown with 4 decimals (after the decimal point or decimal comma). This is useful when converting small amounts of certain currencies, e.g. Lire (ITL = Italian Lire). For a display with two decimals, click on the corresponding radiobutton.
  7. Enter an invalid value in the EDIT-box (like 20,5,7 or ABC) and try a conversion. Delphi responds with an error message and pauzes the execution of the application: when trying to convert the text "20,5,7" or "ABC" to a number, Delphi's Debugger noted the error condition. The Debugger shows design errors as well as runtime errors!

    Error message from Delphi
  8. Click the OK button in order to close the error-dialogbox. Then press key F9 (this is the same as the menu-command Run). Execution of the program is resumed and you see a second error message. This is the warning we programmed ourselves. Only this message will be shown when there is an invalid input when you run the program from Windows Explorer or from My Computer. Also close this dialogbox by clicking it's OK button.

  9. Enter a number with a decimal fraction in the EDIT-box. For the decimal separator, you can type . (point, dot) as well as , (comma): not only 10.5 but also 10,5 is accepted. The program does this by looking at Windows' "Regional Settings" and by replacing the comma with a point. Or vice versa, of course.
    This is a golden tip if you make applications for both Anglo-Saxon and non-Anglo-Saxon users. Especially the Americans tend to forget that there are a few countries besides the US of A...
  10. Type a number in the EDIT-box and press the ENTER key: just as if you clicked the "equals" button! This gimmick is programmed as follow: if the EDIT-box has the focus (meaning: if the text-cursor is visible in this object) and if you press ENTER, a click on the "equals" button is simulated.
  11. Stop the program via it's menu and Exit, via it's sytem menu, or via it's Close-button (top right of the window).
  12. Stop Delphi. If you get the question "Save changes to...?", say no. Because maybe you changed something in the source code and for the moment we don't want to save these changes.

Euro Currency Convertor as a standalone program

  1. Start Windows Explorer and look in the folder where our first project is located. You will see several additional files:
    • euroccen.exe is the executable file
    • euroform.dcu (dcu= Delphi compiled unit) is the file that was compiled from the source files euroform.pas (pas= Pascal) and euroform.dfm (dfm= Delphi Form)
    • euroccen.dsk (dsk= Desktop) is the file that remembers how your Delphi-desktop looked like when you stopped Delphi. Next time when you open the same project, the positions and dimensions of all the windows will be restored. Nifty!
    • other files: if you fooled around with the project. In the next lessons I'll discuss all those Delphi-files in detail.
  2. Doubleclick on euroccen.exe: the program starts.
  3. Try again to convert an illegal value. Now, you will only see the programmed error message.
  4. Stop the program.
  5. If you want to see how EuroCC reacts to a different setting of the "decimal separator", you open Windows' Control Panel, you open the Regional Settings and you change the "Decimal symbol": enter a point if it was a comma (or the opposite: enter a comma if it was a point). Close the window Regional Settings.
  6. Start EuroCCEN from the Explorer and note that the results are displayed differently: with decimal points instead of comma's (or the opposite, of course). Try a value with a decimal fraction: also in the EDIT-box this same decimal separator is shown, no matter if you type point or comma.
  7. Stop the EuroConvertor. Afterwards, don't forget to reset your Regional Settings back to the way they were.
You can freely download lessons 1 to 3 of our Crash Course Delphi and the associated source code files.

Members of the DelphiLand Club can also download the other lessons and our specific tutorials, including all fully commented source code files.

TOP   HOME      LESSON 2 Lesson 2