Section 8: Code completion, Macros, Some important options dialogs
Delphi, as you will no doubt have already started to realise, provides a rich feature set of time saving programming aids. There are
still some more goodies to come however!
Code completion
If you read the previous section, you will have noticed that we alluded to the MS Word's use of threads to perform activities like
the background spell check. Delphi does a similar job, except in its case, the background task is one of compilation. All the time you
are typing, Delphi is checking your syntax. The advantage that this conveys, is that at all times, assuming the code contains no
syntactic errors, the IDE can suggest what it is that you might have intended to type next. It does this in three major ways.:
1) If you type part of an object and press the full stop key, the IDE will check all of the available fields, and list any that make
sense in the current code context. You can then cursor through the list, and press enter to accept the compiler's suggestion, or you can
continue to type, as you wish.

Figure 19 Code Completion in Action
2) If you are typing a function, procedure or method call, and that call requires parameters, as soon as you open the brackets, Delphi
lists in the form of a hint, the parameters that the call expects (in the form of the function/procedure/methods prototype). What's more,
as you fill in your selected parameters, the IDE will highlight the particular parameter that you should be providing next.
Figure 20 Parameter Hinting In Action
3) Any time a variable is expected, it is possible for the developer to type Ctrl-Space, and the IDE will provide a pop up list of all of
the possible variables that are both in scope and of an appropriate type to complete the statement. The programmer can then either
continue to type or use the up and down cursor keys to select the required list item.
These three features save the programmer an enormous amount of time hunting through manuals, help files, and code files to find the
answers. This is a very useful facility, but again there is a downside. As the application grows, the background compilation process can
take up a significant amount of processor time, and hence the IDE's responsiveness can begin to suffer. Fortunately, the code completion
facility can be turned off, and in any case, you do have to be building a particularly large application for this to be an issue.
Macros
Delphi provides exten
sive template/macro facilities. These allow the programmer to generate in skeleton form, the constructs that are most often used in the
language (for loops, case statements etc...) and to call the template up at any time, with the cursor ready positioned to
add the flesh to the skeleton. Nearly all of the templates a Delphi programmer is likely to use on a regular basis are provided already,
in editable format, in the IDE. To call up a template whilst typing, the developer types Ctrl-J, and then either types the Macro
identifier, or uses the cursor keys as before to select from the drop down list. It is possible to modify the default templates, add new
templates and remove existing ones by selecting Tools, Environment Options. The Code insight tab of the resulting dialog provides the
settings control for all of the code completion and code template facilities.
Figure 21 Calling up a Code Template whilst Editing
Controlling the IDE - Important Dialog Boxes
There are relatively few dialog boxes in the IDE, in fact there are only three which you could consider to be really important in
terms of configuring the IDE and the way in which the compiler generates its code. However, these dialog boxes are quite complex, and
comprise (in all cases) a number of tabs.
To control the way in which the compiler operates, and generates its code, select from the Project menu the "Options" item (the last
entry in the menu). This provides the dialog box shown below:
Figure 22 The Project Options Dialog
Amongst other less important settings, the project options dialog allows the
programmer to set the following:
The way in which the syntax of the language is parsed
The style of code generated by the compiler
The level of error checking included in to the executable
The amount of debugging information included in the executable
The Icon to be used to represent the application's executable file
The Title of the Application
The Embedded copyright and versioning information to be included
The name of the help file to use with the application
The search paths for any external files required to build the application
We will talk more about exceptions later in this course, but for now, if you are unfamiliar with them, all you need to know is that
they are a kind of internal signal that signals the occurrence of an error condition. The Debugger Dialog box (Tools, Debugger Options)
shown below, allows the user to configure exactly how the IDE responds to exceptions if one should occur during a debugging session.
>
Figure 23 The Debugger Options Dialog Box
Finally, the Environment Options Dialog box (Tools, Environment Options) allows the programmer to configure the usability aspects of
the IDE. The more important facilities include:
The code completion settings
The code template settings
The colour coding of the syntax highlighting used by the editor
"Comfort" settings for the program editor
Settings for the object browser (more of this later)
It is well worth familiarising yourself with these 3 central dialog boxes. They are the hub of the application, and once you realise
that there are only these three, finding your way around the IDE becomes a lot simpler.
Now that we have completed our tour of the IDE, and we know what Delphi is all about, we are ready to begin the programming elements of
the course in earnest. In the next section we provide an introduction to the concepts of programming in an Object Oriented style.
Menu: Home, Services, Events, Features, Interviews, Profiles, Reviews, News, Resources, Press