Professional Documents
Culture Documents
Across the top of the window is the title bar with the minimise,
maximise and close buttons on the right-hand side. Under the
title bar are eleven menus.
The File, Edit and Search menus have all the usual Windows
options, whilst the other menus contain options specific to the
C++ environment.
At the bottom of the screen is an information bar that provides
information on the current operation and displays the cursor
position as line and column number.
Borland C++ 1
The Menus The File menu provides commands for creating new files,
opening existing files, saving, printing and exiting the C++
environment.
The Edit menu provides the usual cut, copy, paste and
clipboard commands.
The Search menu allows you to find and replace text and to
search for objects and symbols in the program you are editing.
The View menu allows you to view a number of windows
containing program and environment information.
The Project menu is for the manipulation of project files and
control of all aspects of a project, allowing you to compile all or
part of a program.
The Script menu provides facilities for creating, managing
and running program scripts
The Tool menu allows you to run other programs, tools and
utilities useful in the development of Windows applications,
without leaving the IDE.
The Debug menu provides commands for running and
debugging programs.
The Options menu allows you to edit project and environment
settings and save them to a configuration file.
The Window menu contains window management commands
and selections.
The Help menu gives you access to on-line help including
programming syntax, examples and library information.
Pointing to a menu option and holding down the mouse button
displays a description in the information bar at the bottom of
the screen
The SpeedBar Below the menu bar is the SpeedBar. This consists of a line of
buttons that represent commonly
performed tasks. Initially there
are only 5 buttons for opening and
saving files and projects but more will appear when you start
creating files. The full bar will then look like this:
2 Borland C++
To remove the SpeedMenu, click the left mouse button
anywhere outside the menu.
Creating And Programs are best created as part of a project. Projects will be
Running a Program described in more detail later. For now,
Borland C++ 3
Click on the OK button and a new window appears at the
bottom of the screen with a graphical representation of the
project you have just created:
Notice that the project has several levels or nodes, the top is
the executable file with the file extension .exe. Next there is
the source code file with the extension .cpp.
At this stage the executable file and the source file are empty -
they have just been created. You now need to write some code.
Writing The Program Double click on the source filename to produce an empty
Edit window then type in the following simple program
making sure the syntax is correct:
A window titled
Compile Status
appears over the Edit
window informing
you of the progress of
the compilation and
linking sequence.
If the compilation is
successful, the
program will run
automatically in an
output window with
the name of the
program at the top.
4 Borland C++
The program prints the words “hello world”:
Borland C++ 5
in which you accepted the default settings for the example
program. The options are described more fully here.
Filenames The names of most generated files in a project are derived
from the name given to the project file, though they will have
different extensions.
The general convention for filenames is:
Project file .ide
Executable file .exe
Source file .cpp or .c
Target Types In addition to .exe files, the target may be a static library file
with an extension of .lib, a dynamic link library with an
extension of .dll or a Windows help file with an extension of
.hlp.
The setting used for Target Type will determine the range of
platforms that can be chosen for the program. Choosing
Application gives a choice of all types of platform (DOS, 16-bit
Windows and 32-bit Windows), whilst selecting EasyWin only
offers 16-bit Windows as a platform.
Target Platforms You should choose a target platform according to the system
on which you intend to run your program. Options include 16-
bit Windows, 32-bitWindows or standard 16-bit DOS
applications with or without overlays.
Target Models The target model refers to the memory model to be used. Small
is sufficient for many programs. If you find that you have
memory problems when compiling or running the program,
you can change the memory model to make use of more
memory. Models change depending on the target type.
The Project Tree The project tree will always show all the files associated with
the open project. A node containing a + sign indicates that it is
dependent on other files. These can be viewed by clicking on
the + sign. When this is done, the dependent files are revealed
and the + changes to a – sign.
Under the source node of the project tree you might see several
files that were added to the project when it was compiled by the
project manager. The full tree may look something like this:
6 Borland C++
Making If you have previously built a project and have made changes
to parts of it, choosing ‘Make all’ from the Project menu will
rebuild only those files containing changes since the last build
plus any files dependent on them.
It is also possible to build or make individual nodes of a project
tree. To do this, select the node of the tree by right clicking on
it, then, from the SpeedMenu, choose either ‘Build node’ or
‘Make node’.
Editing A The project tree can be edited by adding or deleting files or
Project Tree nodes, changing node and target
attributes or moving targets and nodes.
To change a node in the project tree, make
the Project window active and right-click
on the node to reveal the SpeedMenu then
choose the required option.
The options available will vary depending
on the type of node selected.
Copying Project To copy nodes from one part of a project to
Nodes another or to another project, select the
node to be copied, hold down the CTRL key
and drag the selected node to the required position in the
project tree. All the dependants of the node are automatically
copied.
Setting Project Once you have created a project, you may need to change the
Options default build options. These options tell the project manager
how to build the project (for example, they specify whether
debugging information is to be included or if optimisation is to
be performed). Project options are used to build the entire
project and are also passed on to any new projects you create.
To change project options, choose Project from the Options
menu to produce the following dialogue box:
The options are listed on the left. Those with a + next to them
contain further options that can be viewed by clicking on the +
sign. This will also reveal a brief explanation of the option
highlighted.
Further clicking on a sub-heading enables the options to be
changed by entering text in or by checking or unchecking the
appropriate box.
Borland C++ 7
Style Sheets The options set for a project form a Style Sheet. The settings in
a Style Sheet determine how the project is built. If all the
components in a project can be compiled with the same
options, these can be set in the Project section of the Options
menu.
However, if you want to build different nodes in the project
with different options, you can set a Style Sheet for that node or
use local override as detailed below.
When the project manager builds a node, it refers to the node’s
Style Sheet and any local override options. If the node does not
have a Style Sheet of its own, the project manager uses the
Style Sheet of the node’s parent.
If the parent node does not use a Style Sheet, the manager
looks at the next parent, continuing until it uses the project’s
Style Sheet.
Overriding Project Sometimes you might need to use different options to the
Options default for a particular file or node so you will want to override
the project options locally.
To do this:
Right-click on the node whose options are to be overridden.
Choose ‘Edit local options’ from the SpeedMenu. This
produces the Style Sheet dialogue box containing the node’s
options.
Select the option you wish to override and the Local
Override box is checked automatically.
Click OK to complete the procedure.
Saving Options Any changes you make to the project options will be effective
for the current session, including new projects. By default, the
settings are also automatically saved in a configuration file for
future sessions.
Debugging Programs No matter how careful you are when you write your code, your
program is likely to contain bugs or errors that prevent it from
running. There are three basic types of error: compile-time
errors, run-time errors and logic errors.
Compiler errors are due to incorrect syntax in your program
and will be shown in the Message window at compile time.
Run-time errors are due to statements not being executed or
giving an inappropriate result for some reason such as an
attempt to open a non-existent file or to divide by zero. These
will cause an error message to appear on execution.
Logic errors are errors in design and implementation such
that, although the program works, it may not be doing what
you intended. To track down these errors use the debugging
facility of the IDE.
Running The To use the debugger you must first compile and link the
Debugger program with debugging options on. This is, in fact, the
default setting but to make sure, choose Project from the
Options menu then select Compiler/Debugging to see that the
option 'Generate debug information' is checked in the
dialogue box.
The debugger allows you to step through the program one
statement at a time allowing you to examine the state of the
program and check the values of variables.
8 Borland C++
Stepping To step through the code choose Step into from the Edit
Through Code windows SpeedMenu or click on the Step into button in the
SpeedBar. To follow the code in called functions, use Step over
instead
To run the program to a specific location, position the cursor
at the line where you want the program to halt, then choose
Run to current from the SpeedMenu or the Run to here button
in the SpeedBar.
Setting Breakpoints A breakpoint is a designated position in the code where you
want the program to stop executing and return control to the
debugger. This is similar to using Run to current except that
there may be multiple breakpoints in a program.
To set a breakpoint, move the cursor to the required line of
code in the Edit window then choose Toggle breakpoint from
the Debug menu or the window’s SpeedMenu.
Now, when the program runs, it will stop at the breakpoint
before executing the code. Note that the code at a breakpoint
must be executable
To delete breakpoints, move the cursor to the line and choose
‘Toggle breakpoint’ again.
Examining And To see the current values of variables or expressions choose
Changing Values Watch from the View menu. This will open the Watch window
that is initially empty. Choose Add watch from the Debug
menu and type in the name of the variable or the expression
you wish to view.
You can also modify the values of variables by using the
Expression Evaluator dialogue box. To use this, choose Modify
from the Evaluate option of the Debug menu. Enter the
variable in the expression box then type the new value in the
New Value box. To make the new value take effect choose
Modify, otherwise the debugger will ignore the new value.
Stopping There are two ways of stopping the program executing; these
The Program are Pause process and Terminate process, both of which can
be chosen from the Debug menu. When using Pause process,
you can resume execution from the same point by choosing
Run from the Debug menu.
If you choose Terminate process, all subsequent running,
stepping or tracing will begin at the start of the main
program.
Browsing Code The Browser allows you to view the objects, functions, classes,
variables, types and constants used by your program. To use
the Browser, the program must be compiled with certain
options set in the Project Options dialogue box. To do this,
choose Project from the Options menu, then choose
Compiler/debugging from the topics available.
As well as the debug options previously mentioned, you should
make sure that the option ‘Browser reference information in
OBJs’ in the Compiler/Debugging section is checked.
To see an overview of all objects in your program choose
Classes from the View menu. This will produce a hierarchy of
dependent relationships.
Borland C++ 9
To see a list of all the symbols in the program choose Globals
from the View menu. This produces the following window:
10 Borland C++