What you are going to learn today:
You're not in the '90s if you don't know Windows - and the latest rage in programming are the Rapid Application Development (RAD) systems. RAD is just a term used to describe programming systems which make programming fast, easy, and efficient, and as you'll see later, this is totally true.
Delphi? Wealthy? Healthy?Those of you who program in Windows may have heard of VB, the (in)famous RAD development system for Windows created by Microsoft. Although easy to use, VB has the following weaknesses:
How do we use Delphi?First thing you must learn about Delphi programming - the process goes Draw, Change, Code. First, 'draw' your program on the screen, change what you've just 'drawn', then write code to accompany the program. To 'draw', you must first locate the big blank window on your screen which looks as if it had 'a bad case of measles'. (That line was lifted from Delphi Programming for Dummies!) This is where you start drawing your programs - select the button with the big 'A' on the top of the screen and drag across the 'canvas'. Instantly, a giant label appears on the screen, with the text: 'Label1'. Get the idea? Flip to the other tabs and see what other things you can 'draw'. Some things, however, don't show up on the screen. They just remain a small icon stuck there with super-glue or something. Like any other painting tool, you can remove these items by selecting it and pressing Delete. Now that you've drawn something, you might want to change their properties. For instance, you might want this Label to be blue. Simple, just use the Object Inspector to change it. In a sense, you're changing what you've just 'drawn'. Isn't that great? Much better than your old Crayola crayons.
To change an object property, you look it up on the Object Inspector, then change its value on the right. For instance, to change the text on the label, you can change its 'Caption' value to 'Delphi!' Some properties, you may also notice, have a '+' sign right before its name. This means that that property can be expanded by double clicking on its name - for instance, you can double-click on 'Font' and change its 'Color'. You'll see a pull-down list with all the possible values you can use to define its colour. Change it to clBlue for instance, or clGreen. You'll see that the colour of the text changes accordingly. Now you're getting the idea! Play around - All great fun! You're playing with colours, right? You can also double double click on the value to bring up a colour selection box. Ooo, ahhh...
Enough. Now that you have customised what you have 'drawn', the next step is to add code to each object. Look back at your Object Inspector. Notice that you've only been looking at the 'Properties' tab, the one you used to change your 'drawing'? Click on the second tab 'Events', and voila! You see the list of events linked to the object that is currently selected. See, the 'OnClick' event is activated when the object currently selected is clicked. Considering that you haven't done anything stupid, the following steps would create a 'Hello World!' application.
Wait for a moment as your hard disk lights flash... Poof! Instantly, a great window appears on your screen, beckoning you to click on it. Do so. At once, the title bar changes to say 'Hello World!' It works! Your first Delphi program works! Let's look at your code: First of all, as your code was for the form's OnClick event, your code would only be executed when the form gets clicked. When it does, it sets the Caption member of Form1, which is the form, to become 'Hello World!' Huh? Well, look at it this way. The form is actually a record, and you're setting the Caption property to become what you want it to be. (And as you'll see later, the form is not only a record, it's an object!) Just treat the form as a record for the moment and you'll be okay.
Exploitation Time!Now that you've had a taste of Delphi, it's time to tell you of our devious plans... We plan to use Delphi to teach all of you the concepts of Windows and Object Orientated Programming, the two main topics of Class A. What? You don't have Delphi? Well, get it! Better now than never. Let's give you our top 10 reasons why you should get Delphi now:
End Of Day 10As you can see, Delphi is very different from the console Turbo Pascal you've been learning so far. Who knows, you just might give up Turbo Pascal programming altogether! Some of you may be puzzled though. Why is it that Delphi executes code only when an event occurs? Well, you'll find out in Day 11! So good luck!