The Delphi Toolbar

This is the main toolbar for Delphi 1 you will come to know this very well, only practice will remind you where the component you are after is on this toolbar, as you can move them if you so wanted, you could just have the one component section and have them all in it, but it has been carefully thought out, and components have been grouped to help you find them quickly.
To the left there are number of speedbuttons
|
Open Project |
|
|
Close Project |
|
|
Add file to Project |
|
|
|
Remove file from Project |
|
|
Open File |
|
|
Save File |
|
|
View Unit |
|
|
Toggle form/code view |
|
|
View Form |
|
|
New Form |
|
|
Run |
|
|
Trace Into |
|
|
Trace Over |
|
|
Pause |
![]()
Associated Programs
These programs can be found under Tools on the menu bar.
|
ReportSmith |
A reporting tool. |
|
Image Editor |
A utility which creates all images associated with resource files for Delphi. |
|
Database Desktop |
A complete database management tool for Delphi. |
|
BDE Config |
Configure the Database Desktop |
Standard Bar
TMainMenu, TPopupMenu, Tlabel, TEdit, TMemo, TButton, TCheckBox, TRadioButton, TListBox, TComboBox, TScrollBar, TGroupBox, TRadioGroup, TPanel
Additional Bar
TBitBtn, TSpeedButton, TTabSet, TNotebook, TTabbedNotebook, TMaskEdit, TOutline, TStringGrid, TDrawGrid, TImage, TShape, TBevel, THeader, TScrollBox
Data Access Bar
TDataSource, TTable, TQuery, TStoredProc, TDatabase, TBatchMove, TReport
Data Controls Bar
TDBGrid, TDBNavigator, TDBText, TDBEdit, TDBMemo, TDBImage, TDBListBox, TDBComboBox, TDBCheckBox, TDBRadioGroup, TDBLookupList, TDBLookupComboBox
Dialogs Bar
TOpenDialog, TSaveDialog, TFontDialog, TColorDialog, TPrintDialog, TPrinterSetupDialog, TFindDialog, TReplaceDialog
System Bar
TTimer, TPaintBox, TFileListBox, TDirectoryListBox, TDriveComboBox, TFilterComboBox, TMediaPlayer, TOleContainer, TDdeClientConv, TDdeClientItem, TDdeServerConv, TDdeServerItem
Other components can be installed into Delphi (in fact you can create your own), so there may be other components available, but these are the ones that come provided with Delphi 1.
A computer language is much like any languages it comprises of sentences. By this idea, a program is like a book, it has sentences, paragraphs pages, and chapters, however, a sentance is a code statement, a paragraph is a code section, and a page is a procedure or function and a chapter would be a module or unit, the book itself would be an application.
Important things to remember
In Delphi all code statements are terminated with a ';' |
|
If you think of normal books if a character in the book says something you would have Tracey says "Hello", in Delphi the way this would be written would be Tracey says 'Hello'; This may seem strange, but this is how pascal has always been, and Delphi's grand father is Pascal. |
|
If you want to change the value of something, bank_account for example, you would set a value to it by using the ':=' think of it as becomes equal to, rather than '=' which is equals, you will see why later on. So, to change bank_account to 5000 you would say bank_account:=5000; |
All programming evolves round the following programming methods, below is the format of the statement, what it means an an example of how to use it - dont worry if the example does not make sense.
A variable is like a programmers post-it note, you use them to remember numbers, copies of something else or the results of a calculation. In Delphi you must delcare a variable before you use it, and Delphi needs to know what sort of information you are going to keep there and often how big this is likely to be - this is so a) when it looks at it it knows what it should be doing with it and b) that the post-it is big enough.
Example:
var
x : integer;
begin
x:=5;
end;
You will have noticed that I declared by variable by using the var command, if I had had more than one variable to declare, I do not repeat the var command.
Example:
var
x : integer;
name :
string;
There are many more types of variables, and in fact you can almost define your own, this will be covered later - but at least you have a start.
Without a begin and end all parts of Delphi assume there is only going to be one sentance, the begin and end mark a group of code statements, just like a paragraph denotes a group of related sentences.
Example:
Begin
x:=5;
name:='Liz';
end;
| If...then...else...; |
Often you will yourself effectively perform this task without even thinking about it, for example think of a simple waking up process. Is it dark? If it is dark turn on the light, if it is not dark you do not have to turn on the light. To code this into Delphi you need to use the following format
IF question THEN do_true_code_statement ELSE do_false_code_statement;
The question must return one of two values true or false. You could say 'is the color of my shirt blank' the answer to this question is always yes or no (true or false), you could not say 'what is the color of my shirt' as this would result in many possible answers to answer that question you must use something else.
Example:
If age >= 18 then
adult:=true
else
adult:=false;
If you dont require your program to do anything if the question is not true then you may omit the else part of the statement.
Example:
If dead=true then
exit;
You may also need the program to do more than one thing if the question is true and/or more than one thing if the question is not true.
Example:
If age >=18 then
Begin
adult:=true;
entry_cost:=9.25;
end
else
Begin
adult:=false;
age:=date-date_of_birth;
end;
Please note that the end before the else does not have a ';' after it, this is because you havent finished your coding statement.
| For...to/downto...do...; |
Sometimes you will need repeat a code statement or section a number of times, the loop may be an incremental loop, or a decremental loop and you may not want the loop to go increment or decrement in stages or one. For example a count down from 10 to 1.
Example:
For x:=10 downto 1 do y:=y+1;
This code adds 1 to y for each time the code goes round the loop. If you were to go from 1 to 10, you would need to do for ... to... do...; If you were to write out the code long hand for this loop this is how it would work
x:=10;
y:=y+1;
x:=9;
y:=y+1;
x:=8;
y:=y+1;
x:=7;
y:=y+1;
x:=6;
y:=y+1;
x:=5;
y:=y+1;
x:=4;
y:=y+1;
x:=3;
y:=y+1;
x:=2;
y:=y+1;
x:=1;
y:=y+1;
While this code may not be too bad for a small loop like this, imagine if it was going to go round 1000 times.
To make the loop progress with different increments you have to use a step, so to count 2 4 6 8 you would do
for
t:=2 to 8 step 2 do.....
| While ... do ... ; |
Often you need to repeat some code until something changes, there are two ways of doing this the While statement and the Repeat statement, both achieve something very similar, but there is one major difference, you will see when you read the Repeat statement. The while statement asks the question if this is true it goes on and does the code in site the do part of the statement and goes round back to ask the question and does this until the question is no longer true, when question is no longer true it skips the do part of the statement and allows the program to continue on down the code.
Example: (In this example the user has provided a number x)
While x>0 do x:=x-1;
This will go round the code until x=0 - of course, if the user entered -1 the code would never finish this is something you may have to think of.
| Repeat ... Until ... ; |
As above you often need to repeat some code, the Repeat statement performs a line of code and then asks a question, if this question is not true it repeasts the line of code and asks the question again, it does this until the question returns true.
The difference between the Repeat statement and the While statement is that the While loop may never do the code within the do section because if the question that the While loop asks is not true before it starts it will never be done, where as with the Repeat loop, it will always be done at least once.
Example:
Repeat x:=x+1 Until X=10;
![]()