As the people from Inprise
(was: Borland) put it so nicely: Delphi is an object-oriented, visual
programming environment for "Rapid Application Development" (RAD).
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, Windows 98 or Windows NT.
What about Windows 3.x? Well, you can develop 16 bits programs with the 16-bit Delphi 1,
included on the same CD as the 32-bits version. But I won't talk a lot about that Delphi first version.
In a future lesson, I'll treat the differences between the 16-bit and the 32-bit versions.

For starters, let me tell you a few general things about my lessons.
 |
The lessons are mainly about Delphi 4, although most of the stuff will hold for D3,
and part of it is even true for 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
next lessons we'll make the program Acron.
For those who are too impatient: the exe-file of Acron can be found in DelphLand's download
section as ACRONX.ZIP.
Also download ACRODAT1.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 ACRODAT2.ZIP, and
afterwards..., and so on).
By the way (BTW), D1 means "Delphi 1", so D4 is... Correct.
For "the 32-bits versions of Delphi, D2, D3, D4 and later probably 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
Create a new folder (directory) \DelphiLa on your harddisk (C:, D:, E:...).
Then download the first group of lessons, les0105.zip. Put the file in \DelphiLa and unzip it.
Create directory EuroCCEN under \DelphiLa, download euroccen.zip (source code for our first finished project) to \DelphiLa\EuroCCEN and unzip it in this directory.
When checking with Windows Explorer, you'll see euroccen.dpr, euroform.dfm and euroform.pas.
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:
- Doubleclick in Windows Explorer (or in My Computer) on euroccen.dpr: Delphi starts and it
opens the project "euroccen".
- Open Delphi's Run menu and click Run.
- 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!
- 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.
- Click on one of the radiobuttons for the starting currency, for example BEF/LUF.
Note that the corresponding label 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.
- 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.
- 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!
- 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..
- 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...
- 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.
- 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).
- 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
- Start Windows Explorer and look in the folder where our first project is located. You will see
several additional files:
euroccnl.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);
euroccnl.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.
- Doubleclick on euroccnl.exe: the program starts.
- Try again to convert an illegal value. Now, you will only see the programmed error message.
- Stop the program.
- 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: replace the COMMA by
a POINT).
Close the window Regional Settings.
- 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.
- Stop the EuroConvertor. Afterwards, don't forget to reset your Regional Settings back
to the way they were.
[ TOP ]

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... ;-)


[ TOP ]
© Copyright 1999
Studiebureau Festraets