Lesson 1: 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 applications for Windows 95/98 or Windows NT.

Delphi is a so-called RAD (Rapid Application Development) tool. Delphi 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 the 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!

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

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


For starters, let me tell you a few general things about my lessons.

Although the lessons were initially written for Delphi 4/5, most of the stuff will hold for D3 and D2.
Hyperlinks are used abundantly for explanations and tips. So you'd better start practizing with the BACK-button of your browser, because that is the only way to return to the current lesson ;-)
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 ACRODAT3.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 ACRODAT4.ZIP, and afterwards..., and so on).
By the way (BTW), D1 means Delphi 1, so D5 is...? Correct. For "the 32-bits versions of Delphi, D2, D3, D4 and D5" I came up with the very original D2+.
Run before you can walk? Yes, that's possible with Delphi! No need to start studying Turbo Pascal, no need to know anything about object orientation. 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!

Preparations

  1. If you haven't done so already, create a new folder (directory) \DelphiLa on your harddisk (C:, D:, E:...). Next, download the first series of lessons les0103.zip from the Downloads section to this directory and unzip it.

  2. If you haven't done so already, create directory EuroCCEN "under" \DelphiLa. Next, download euroccen.zip (source code for the first finished project) from the Downloads section to this directory and unzip it. 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!

    EuroCCEN

  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.

    EuroCCEN

  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.

    warning

  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:

  2. Doubleclick on euroccnl.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.


Navigation
Not the only way of course... You can also return to the current subject by means of the navigation menu and then work your way back to where you were. But since the browser has a BACK button... ;-)

You can freely download lessons 1 to 3 and the associated source code files.

Members of the DelphiLand Club can also download the full version of lessons 4 to 10, including all fully commented source code files.

[ TOP ]

© Copyright 2000 
Studiebureau Festraets