You are on page 1of 40

Chapter III

Turbo C++ IDE

Chapter III Topics

3.1 The Need For A Text Editor


3.2 Getting Into The Turbo IDE
3.3 Moving Around The Turbo IDE
3.4 Getting On-Line Help With <F1>
3.5 Basic Editing And Filing Features
3.6 Working With Blocks
3.7 Finding The Proper Directory
3.8 Running A Small C++ Program
3.9 Working With Multiple Files
3.10 Using Hot Keys
3.11 Different Turbo C++ Memory Models
3.12 The Turbo C++ Selection Menu
3.13 Turbo C++ 3.0 and Standard C++

3.1 The Need For A Text Editor


Chapter III The Turbo C++ IDE 3.1
Writing programs in early "interpretive" languages, like BASIC was quite simple.
You used line numbers to indicate the sequence of your program text. If more text
had to be inserted in an existing program, you would use appropriate line numbers to
place the text where you desired it.

A compiled language such as Pascal, C or C++ does not use line numbers. The
program execution is controlled by the sequence in which the statements are written.
Some means must be used to write the source code. Since the program is essentially
a large file of characters, it is text that can be written by any text editing type of
program, like a word processor.

Turbo C++ makes your program writing simple. You are provided with
considerably more than a compiler that translates your programs into machine code.
The Turbo C++ Integrated Development Environment - called IDE from now on -
provides a Text Editor, File Handler, Compiler, Debugger and many other
features all in one. Before you even consider learning anything about programming
in C++, you will first need to learn how to work with the Turbo IDE. If you have
never used a word processor, you will find an added benefit from learning computer
programming. You will learn text editing that can be used for other subject areas as
well. Take the time to read and study this chapter well. In the beginning, you will
need this material very frequently. If you are using another compiler, the same logic
applies. You will need to learn how to use the program environment that you are
using. This chapter explain Turbo C++, Version 3.0 IDE, because that is the IDE
that is currently used in the Richardson school district for beginning students.

3.2 Getting Into The Turbo IDE

There is considerable flexibility in entering the Turbo IDE. Computers today


usually run in some type of windows environment. Many run on a network system
and the manner in which software is accessed can be different in every computer lab
situation. Still, there are certain common patterns. In a stand-alone, windows
system there should be some icon indicating Turbo C++. Double click on such an
icon to enter the Turbo IDE. If you are using a Network system, you will need to
follow the instructions on the screen to select the Turbo C++ software application.
Usually, you will need to click on an icon as well.

You may also prefer to operate in a DOS environment and enter commands at the
DOS prompt. Perhaps your computer automatically boots up in DOS or you have
selected to exit windows and restart to operate in DOS mode. Either way, you now
need to type TC at the DOS prompt.
C:>TC

Type the command TC at the DOS


prompt, followed by pressing the
<RETURN> or <Enter> key.
Chapter III The Turbo C++ IDE 3.2
At Berkner High School, we load different Pascal and C++ versions on the
computer. This is desirable because some versions of a language are better for
program development and other versions are better for learning computer science.
Using a command such as Turbo for Pascal and TC for C++ is potentially
confusing to the computer and you may not get the programming language version
that you wish to use. At Berkner High School, you will need to type TC30 for
Turbo C++ version 3.0.

Right now, the mission is to learn computer science and using the Turbo C++ for
DOS version will make your life simpler in learning the majority of introductory
concepts. The biggest benefit is that the Turbo C++ for DOS environment is simpler
than the windows environment. Do not be confused. It is entirely possible that you
are right now sitting behind a computer running Windows 3.1, Windows 95 or
Windows 98. There is a major distinction between the operating system that you are
using and the C++ IDE. This means that you can run a C++ for DOS environment
as well as a C++ for Windows environment, both from a Windows operating
system. The point is that once you are inside the C++ environment, Turbo C++ 3.0
for DOS in this case, you are not really concerned with the larger computer
operating system.

You will find that rebooting is a common occurrence in learning C++. Students new
to computer science manage to find many creative ways to totally discombobulate
the computer system. In many cases the computer responds by throwing in the
towel and freezing up completely. The only next step is to do a complete "cold
boot" and try again. It only takes a few reboots in Windows95 to realize that this is
not an ideal learning environment. In Windows95, turning off the power for a cold
boot throws Windows95 in a "what-is-going-on-check-everything" check up
mode, which is even slower than normal booting up. You may prefer to run
programs in DOS mode in the early stages.
Let us assume that you have managed, by whichever system you are operating on, to
get into the Turbo IDE. The opening screen for Turbo C++ will now appear,
looking something like what is shown on the next page. Some variations may occur
in the display mode, depending on the type computer and monitor in use.



Chapter III The Turbo C++ IDE 3.3


 File Edit Search Run Compile Debug Project Options Window Help
╔══[]═══════════════════════════ NONAME00.CPP ════════════════════════1═[]═╗
║ ║
║ ║
║ ║
║ ╔═══════════════ About ═══════════════╗ ║
║ ║ ║ ║
║ ║ Turbo C++ ║ ║
║ ║ ║ ║
║ ║ Version 3.0 ║ ║
║ ║ ║ ║
║ ║ Copyright (c) 1990, 1992 by ║ ║
║ ║ ║ ║
║ ║ Borland International, Inc. ║ ║
║ ║ ║ ║
║ ║ ┌──────────┐ ║ ║
║ ║ │ OK │ ║ ║
╚═════ 1:1 ════════ ║ └──────────┘ ║ ═════════════════╝
║ ║
░░░░░░░░░░░░░░░░░░░ ╚═════════════════════════════════════╝ ░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
F1 Help │ Accept the settings in this dialog box

Do not be surprised if you do not see the "About" window in the center of the
screen. This display usually only shows up when you run Turbo C++ for the first
time. This screen is quite intimidating for the rookie Turbo person. There are lots of
words, many strange lines, odd looking arrows and symbols, and few suggestions
what to do next. Feel assured that this screen is bunches less intimidating than
almost any other C++ environment that you might encounter.

Relax, it will all make sense after you play with the different commands. Take it
one step at a time. Besides, in this chapter we will not even attempt to explain the
complete Turbo IDE. You can easily write a healthy book on all the many available
features. At this stage, our main goal is to get you functional and capable of writing
simple programs. When you need advanced features, feel assured that they will be
explained as you come to them.

3.3 Moving Around The Turbo IDE

Right now let us take a tour of the Turbo IDE. Before we can even start to discuss
what all of these selections do, you need to know how to get to them. The Turbo
IDE uses the very popular "window pull-down" approach. Now, this is a DOS
text-based program you are using, which means that these windows are text
windows. This means that they do not look as fancy as the GUI (Graphics User
Interface) windows you see on the MAC, Windows 3.1 or Windows95 operating
system or "for Windows" applications. Fancy or not, our text windows work just
fine. One nice benefit is that you will never have to wait. Text is very fast.

Chapter III The Turbo C++ IDE 3.4


This section will be most beneficial if you are reading it, and simultaneously
following the instructions on the computer. At this stage, you should have typed
TC, TC30 or clicked on some C++ icon and your screen should look like the display
on the previous page. Let us get started now.

Removing the Copyright Message

Press the <Space> bar.


This will remove the "Borland Copyright message"
The screen should now look like the picture below.
If the copyright message does not appear, and the screen already
looks like the sample below, move on to the next step.

 File Edit Search Run Compile Debug Project Options Window Help
╔══[]═══════════════════════════ NONAME00.CPP ════════════════════════1═[]═╗
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
╚════════1:1═════════════════════════════════════════════════════════════════╝
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu

Now before we move on, you need to realize is that practically everything you do
can be done with key strokes or with the mouse. This is quite tedious in the
explanation department. It would be simpler to stick to either the mouse or to key
strokes, but most people like efficiency. The truth is that for some situations the
mouse is better and for other situations, key strokes are better. People also have
preferences, some folks prefer a mouse for everything, others prefer key strokes for
everything, and the third group goes back and forth. Take your pick. It is your
computer, your program assignment, and your business. If it works, and you are
comfortable with a given approach, use it.

Please do not get confused, in each situation you will be given both the mouse
approach and the key stroke approach. Do one, or the other, but not both.

Minimizing, Maximizing and Closing a Window


Chapter III The Turbo C++ IDE 3.5
Text windows in DOS try very hard to simulate the user friendly windows
environment of the MAC or Windows computers. It is not exactly the
same, but there are similarities.

Click on the right-top corner Up-Arrow to maximize a window.


Click on the right-top corner Up/Down-Arrow to minimize a window.

You can also press the <F5> key to maximize a window.


Press <F5> a second time to minimize a window.
<F5> behaves like a "toggle" switch.

Click on the left-top corner small square to close a window.

You can also press <Alt-F3> to close a window.

Closing a window is not a toggle operation. Some other step is required


to open a window that was previously closed.

Opening a Window on the Menu Selection Bar

The Menu Selection Bar offers many options that are available in the
Turbo IDE. You can use the mouse and click on any selection to open up a
window. You can also press the <F10> key. This does not open any window,
but it does move the highlighter to the menu bar. With the arrow keys, you can
move the highlighted selection around.

When you press the <Enter> key, the highlighted selection will open a
window. Once you are at the menu bar you can also press any red letter,
like O for Options and the options window opens up. Keep in mind this
does not work from the edit window. In the edit window, pressing the
letter O will get you the letter O nicely displayed on the screen.

From the edit window, you can instantly open a window with key strokes.
Press <Alt-F> and you will open up the File window. Press <Alt-C> and
you will open the Compile window. In general, the <Alt> key plus the
highlighted letter of any selection bar item will open up that window. The
example below shows the File window opened, by whichever method you
selected to use.

Chapter III The Turbo C++ IDE 3.6


┌───────────────────┐
│ File Edit Search│ Run Compile Debug Project Options Window Help
╔═[│ ╞═════════ NONAME00.CPP ════════════════════════1═════╗
║ │ New │ ║
║ │ Open... F3 │ ║
║ │ Save F2 │ ║
║ │ Save as... │ ║
║ │ Save all │ ║
║ ├───────────────────┤ ║
║ │ Change dir... │ ║
║ │ Print │ ║
║ │ Dos shell │ ║
║ ├───────────────────┤ ║
║ │ Quit Alt+X │ ║
║ └───────────────────┘ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
╚════════1:1═════════════════════════════════════════════════════════════════╝
F1 Help │ Create a new file in a new Edit window

When you open a window, the first selection in the window will be highlighted. In
this case, that means the New selection. The highlighted item is briefly explained at
the bottom of the screen. In this case, it states Create a new file in a new Edit
window. Move the highlight bar up and down with the arrow keys. You will find
that the message at the bottom changes. Do not use the mouse for this exercise.

Some of the selections in the window show three dots after the name, like selection
Open ... F3. The three dots signify that an additional window will open up. In
other words, pressing Save or Quit requires no further selections or decisions, but
selection Open or Change dir... means that you are not finished yet with your
current choice, and you need to make additional choices from other windows that
have not been opened yet.

Chapter III The Turbo C++ IDE 3.7


Moving Around the Turbo 3.0 IDE

[1] Make Selections with a Mouse


Click on any selection with a mouse to open up a window or
to activate a command, such as save or load.
It is not necessary to click on the highlighted letter.

[2] Use Arrows Keys and the <Enter> Key


Press the <F10> key to get to the main selection bar.
Use arrow keys to move to the desired selection.
Press the <Enter> key to open up the selected window.
Continue with arrows keys and <Enter> to open other windows.

[3] Use the Hot Key "Short-Cut" Method


Press <Alt> and any highlighted letter to open a window.
Press the highlighted letter to activate a command or open
any additional windows.

3.4 Getting On-Line Help With <F1>

If you have followed the chapter examples, you should now have the File window
open. If the file window is not open, use whichever method you prefer. With the
file window opened - and no other actions performed - the New selection should be
highlighted.

You will notice that the bottom-left corner of the screen indicates:

F1 Help. Pressing the F1 key gives more detailed help than you get from the bottom
line. For example, highlight Change dir... by moving the highlight bar with the
arrow keys. By the way, using the mouse to select or pressing the highlighted letter
automatically opens up the next window. This is efficient and desirable when you
make selections, but right now we need to make a point. So Change dir... is
highlighted. Now press the <F1> key and you should get the screen display that is
shown on the next page.

Chapter III The Turbo C++ IDE 3.8


┌───────────────────┐
│ File Edit Search│ Run Compile Debug Project Options Window Help
╔═[│ ╞═════════ NONAME00.CPP ════════════════════════1═════╗
║ │ New │ ║
║ │ ╔═══════════════════════════ Turbo Help ═════════════════════════╗ ║
║ │ ║ ┌───────────────────────────────────────────────┐ ║ ║
║ │ ║│ │ ║ ║
║ │ ║ │ File│Change Dir... │ Cross Ref ║ ║
║ ├──║ │ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ │ ║ ║
║ │ ║ │ File│Change Dir brings up the │ ║ ║
║ │ ║ │ Change Directory dialog box, where you can │ Previous ║ ║
║ │ ║ │ specify a drive and a directory to make │ ║ ║
║ ├──║ │ current. │ Contents ║ ║
║ │ ║│ │ ║ ║
║ └──║ │ The current directory is the one where Turbo │ Index ║ ║
║ ║ │ C++ saves files and looks for files. │ ║ ║
║ ║│ │ ║ ║
║ ║ │ When you use relative paths in the Options│ │ ║ ║
║ ║ │ Directories dialog box, they are relative │ ║ ║
║ ║ │ only to this current directory. │ ║ ║
║ ║│ │ Cancel ║ ║
║ ║│ │ ║ ║
║ ║│ │ ║ ║
║ ║ └───────────────────────────────────────────────┘ ║ ║
║ ║ ║ ║
║ ║ ║ ║
║ ╚════════════════════════════════════════════════════════════════╝ ║
╚════════1:1═════════════════════════════════════════════════════════════════╝
F1 Help │ Use cursor keys to navigate through help topic

The on-line help feature in the Turbo IDE is very powerful. Basically, you have a
reference manual available right on the screen. It amazing how much you can learn
by playing around with the different selections and checking the help windows. This
chapter will not even come close to explaining all the available features. The mission
of this chapter is to get you started and to teach you how to learn more on your own.
There is no better teacher than the person who is learning. Teachers, instructors,
professors, text books exist to guide students and give them the best tools available
so that students can teach themselves.

Turbo C++ Keywords On-Line Help

For this next discovery exercise, you need to be in the Turbo IDE edit window. If
the cursor is blinking in the large window, you are there. If any window is opened
up, press <Esc> and you will be in the edit window. If the edit window is split,
press the <F5> key to maximize the window or click on the up arrow in the right
top corner to achieve the same result with a mouse.

Right now you know pitifully little about Turbo C++. This chapter makes no effort
to teach you programming in C++ or any other language. The goal here is to use the
Turbo IDE. Now, one important feature of the IDE is to help you understand the
programming features of C++. Any programming language, like C++, has
keywords that have special meaning to the computer. Such keywords must be
Chapter III The Turbo C++ IDE 3.9
spelled correctly, used in the right context and include other special information. All
this keyword business is also provided with on-line help. You can type a keyword
anywhere in the edit window. Make sure that the cursor is somewhere on the word,
and press <Ctrl-F1>. This is a little different. Pressing <F1> gives help with any
highlighted selection in the IDE. Pressing <Ctrl-F1> provides help with any
"cursor-indicated" keyword in the edit window. For now go ahead and type if.
Make sure that the cursor is on the word and press <Ctrl-F1>. You should be
seeing a help window like the one shown below.

 File Edit Search Run Compile Debug Project Options Window Help
╔══[]═══════════════════════════ NONAME00.CPP ════════════════════════1═[]═╗
║ ║
║ ║
║ ╔════════════════════ Help ═══════════════2═════╗ ║
║ ║ ║ ║
║ ║ if (keyword) ║ ║
║ ║ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ║ ║
║ ║ ║ ║
║ ║ Conditional ║ ║
║ ║ ║ ║
║ ║ Syntax: ║ ║
║ ║ if ( <expression> ) <statement1>; ║ ║
║ ║ if ( <expression> } <statement1>; ║ ║
║ ║ else <statement2>; ║ ║
║ ║ ║ ║
║ ║ If <expression> is non-zero when evaluated, ║ ║
║ ║ <statement1> is executed. ║ ║
║ ║ ║ ║
║ ║ In the second case, <statement2> is executed ║ ║
║ ║ if the expression is 0. ║ ║
║ ╚═══════════════════════════════════════════════╝ ║
║ ║
║ ║
║ ║
╚════════════════════════════════════════════════════════════════════════════╝
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu

Right now it is totally unimportant if you understand the explanation of the Turbo
C++ keyword if. What is important that you realize how help is available when you
need it in the future. Also keep in mind that many topics cannot be displayed on a
single window. In such a case, you can press <PageDown> for the next window or
you can click on the down-arrow shown on the scroll bar, located on the right side
of the window. Pressing <PageUp> will return you to the previous window or you
can click the up-arrow on the scroll bar.

In the event that you type a word incorrectly, or type a keyword that you think
exists, but is not part of C++, you will find that the help feature tries to find the word
closest to your choice. Type qwerty and see what happens with <Ctrl-F1>. Use
this help feature. You can discover many neat features.

3.5 Basic Editing And Filing Features


Chapter III The Turbo C++ IDE 3.10
We can do lots of talking, lots of reading, and lots of demonstrating, but learning
occurs with doing. Right now assume that you have just arrived at the computer.
You are about to type information that you need to save in an external file. Let us
take it step-by-step and learn some editing skills along the way. For this exercise
you will need to have a formatted diskette in drive A:. You may also store
information somewhere on a hard drive or somewhere on the network, but for now
assume that you are using a floppy diskette.

Changing TC to the proper drive and/or subdirectory

Type TC, click on an icon, or do what it takes to get into Turbo C++
If the window is not maximized press <F5> or click the up-arrow.

Open the File window with <Alt-F> or click on File.


Select Change dir by pressing C or click on Change dir.

Type A:\ in the directory name box. The cursor should be there already.
Press <Enter> you should be in the edit window now.

This change directory business is frequently forgotten. There are ways to bypass the
Change dir options on and especially the mouse users find ways to access files
without specifying the default directory. I promise you that failure to change to the
proper directory will be a guaranteed major headache in C++. I have seen students
suffer for a long time with non-working programs that were written perfectly. The
only problem was working in the wrong directory.

The problem with changing directory is that it is not significant for the initial
programs. This makes you wonder what the fuss is about. Your own shortcut
method works; it is shorter; it is simpler; why bother? A couple months down the
road you are now totally habitualized into doing it the wrong way, precisely at the
time that it will hurt the most. There are only two approaches. You will have to do
the change directory business at some point. You can develop good habits now or
experience much frustration at some later point.

Why is this so important? That is a problem at this stage. You do not have the tools
to understand what is happening. Please have faith. Trust your teacher, trust this
book and go along. It will be helpful.

Giving Your File a Name

Press the <F3> key or first click on File, then click on Open.
Chapter III The Turbo C++ IDE 3.11
The Open a File window will now be displayed.
If you had previously created a file you could select it now.
However, this is your first time so the window should be blank.
If your diskette contains some files, they may also show up.
Type PRACTICE in the Name box and press <Enter>.

You will notice that the NONAME00.CPP at the top-center of the edit
window is now changed to \PRACTICE.CPP. Turbo C++ automatically
adds the .CPP extension if no extension is specified.

The cursor is located at the top-left corner of the edit window at Row 1,
Col 1. The cursor position is located near the bottom where it shows 1:1.
The screen should have the following appearance:

 File Edit Search Run Compile Debug Project Options Window Help
╔═[]════════════════════════════ \PRACTICE.CPP ═══════════════════════1═[]═╗
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
╚═════════1:1════════════════════════════════════════════════════════════════╝
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu

Now type a few lines of text in the edit window. Use normal typing skills
and press <Enter> at the end of each line. The Turbo IDE text editor does
not wrap around the way a word processor does. This is an intentional
feature since the text editor is specifically designed to edit C++ programs.
It will make sense later that you do not wish to "wrap around." Your
screen should match the screen shown on the next page.

 File Edit Search Run Compile Debug Project Options Window Help
╔══[]═══════════════════════════ \PRACTICE.CPP ═══════════════════════1═[]═╗
║The quick brown fox jumps over the lazy dog. ║
║Now is the time for all good students to learn C++. ║
║This text editor has features that were originally ║
Chapter III The Turbo C++ IDE 3.12
║developed for the popular Wordstar editor back in ║
║the early eighties. ║
║ ║
║Do not be surprised if some words are automatically ║
║highlighted. Turbo C++ displays all C++ keywords in bold. ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
║ ║
╚═════════9:1════════════════════════════════════════════════════════════════╝
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu

Overwrite Mode and Insert Mode

When you are done, make sure that the cursor is on the line following the
last written statement, and in column 1. This is an important habit that
will make future assignment printing much simpler.

Do not worry, if you made some mistakes, copying this passage.


Accuracy in copying is not a priority right now.

Now move the cursor to Row 1, Col 1 on the letter T of word The.

Check the size of your cursor. It is small and skinny. Press the
<Insert> key. The cursor should now be very tall covering the entire
letter T. If your cursor was already big, leave it alone.
Press the letter Q for about 20 letters. You will note that everything below
the Q disappears and is "over written" by the letter Q. You are right
now editing in the so-called "over write" mode. The cursor size indicates
which writing mode the text editor is in.

Press the <Insert> key again. The big cursor should now be small again.
Move the cursor to Row 2, Col 1. This time press a bunches of Zs. you
will notice that the text moves away. You are in "insert mode." Press
<Enter>. You have just inserted a CrLf or Carriage Return, Line Feed.
The <Insert> key toggles between insert mode and overwrite mode.
Deleting Characters and Lines

Chapter III The Turbo C++ IDE 3.13


Move the cursor to Row 4, Col 22. You can determine that position by
the cursor indicator at the bottom of the screen. You can also check if the
cursor is on the letter f of features.

Delete the word features by pressing the <Delete> key. You will notice
that the letter directly underneath the cursor is deleted. Text to the right
side of the cursor moves to the cursor.

Now press the <Backspace> key until the words has and editor disappear.
This time the characters to the left of the cursor are deleted. Everything
to the right stays intact and the left side gets munched. Be aware of this
difference. It is very significant.

A note to Mac users. This feature will seem strange to you because the
Mac does not have a dual delete key feature. To help you somewhat with
the confusion the Mac <Delete> key behaves in the same manner as the
PC <Backspace> key. Actually, if you are a Mac user, this chapter will
be more than a trifle difficult. Turbo C++, Version 3.0 does not operate
on a Mac computer. You will need to get some compiler like
Code Warrior by Metroworks to compile your programs.

Please do not take the time to delete every single character when you need
to delete an entire line. Right now place the cursor somewhere on the line
that starts with Do not be surprised and press <Ctrl-Y>. Presto, the
entire line has been deleted. You will find that Y deletes lines as well as
blocks. It is tough to remember Y for delete. Think of Y as Yank out.

Did you think we forgot the mouse? Not really. Your mouse clicker can
click, drag, a word, a line or a paragraph. Now using the <Delete> key
or the <Backspace> will not remove the highlighted part. Click the Edit
window open and then click on Clear and the deletion is complete.
Personally, I think that the mouse is slow is this case. For large blocks it
is a different story, but not the small stuff. What is faster than a quick
<Ctrl-Y> to delete a line or pressing <Delete> to remove a character?

Moving Around Your Text File

You may be surprised at this section. You were moving around just fine.
The trusty arrow keys make the cursor go anywhere you wish. This is
Chapter III The Turbo C++ IDE 3.14
true, but the cursor only moves one row or one column at a time. This can
be very tedious if your file is 2000 lines long. There are a few short cuts
that will make your cursor move faster.

Place the cursor somewhere in Col 1. The row does not matter, as long
as there is some text on that line.

Now press the <End> key and watch the cursor jump to the end of the
line. Press the <Home> key and the cursor jumps to the beginning.

Now type a bunch of nonsense characters on a bunch of lines. Create


enough new lines to have at least 80 or more lines. Each line can be
very short. Waste no time typing anything that makes sense.

Move the cursor with the up-arrow to the first row. You will only see 25
lines on the screen. A large portion of the file is hidden.

Press the <PageDown> key several times until you are at the last line of
the file. Now press the <PageUp> key until you are back at line 1.

You want faster? We have faster. Press <Ctrl-Pagedown> and watch the
cursor instantly jump to the end of the file. Press <Ctrl-PageUp> and the
file jump to the top of the screen.

Saving Your File to External Storage

If you followed the earlier directions, your file already has the name
PRACTICE.CPP. Saving becomes easy now. You can open the File
window with <Alt-F> and then press S to Save the file.

You can also click the File window open and then click on the Save
selection, but the quickest method is to use a "hot Key." You will notice
in the File window that next to Save there is an <F2> key. From
anywhere in the edit window you can press the <F2> key and your file
will be saved with the current name on to the current default drive.

It is possible that you did not specify a name at the beginning. You are
not interested in saving a file with the C++ default name of
NONAME00.CPP. It is also possible that you have a name but you wish
to change the name. The reason does not matter. Select Save as... to save
the file with a different name.

Chapter III The Turbo C++ IDE 3.15


A window pops open and you can now type in the new name in the "Save
File As" window. Turbo will add the .CPP extension if you only provide a
file name without extension.

Leaving the Turbo C++ IDE

You have done well. Imagine that it is the end of the day, the end of the
period or the end of your computer session. The time has come to exit out
off Turbo C++ properly.

Make sure that your diskette is still in drive A and press <Alt-X>, which
is the quick key combination to exit the Turbo C++ IDE.

You can also click on the File window, followed by clicking on the Quit
selection with your mouse.

Sometimes it is not possible to exit the IDE. Turbo gives you a warning
message, such as the one shown below.

 File Edit Search Run Compile Debug Project Options Window Help
╔═[]════════════════════════════ \PRACTICE.CPP ═══════════════════════1═[]═╗
║The quick brown fox jumps over the lazy dog. ║
║Now is the time for all good students to learn C++. ║
║This text editor has features that were originally ║
║developed for the popular Wordstar editor back in ║
║the early eighties. ║
║ ╔═══════════════ Message ══════════════╗ ║
║ ║WARNING: ║ ║
║ ║ \PRACTICE.CPP ║ ║
║ ║ not saved. Save? ║ ║
║ ║ ║ ║
║ ╟──────────────────────────────────────╢ ║
║ ║ ║ ║
║ ║ Yes No Cancel ║ ║
║ ║ ║ ║
║ ╚══════════════════════════════════════╝ ║
║ ║
║ ║
╚═════════9:1════════════════════════════════════════════════════════════════╝
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu

It is quite possible that you did save your file. You may even think that
the computer is so incredibly stupid. The answer is quite simple. You
wrote the text; you saved the file, and then you made a tiny change.
Perhaps you altered or added one single character. It does not matter how
tiny the change. Any change whatsoever since the last time that you saved
the file will generate the warning message.

Chapter III The Turbo C++ IDE 3.16


Turbo is trying to be nice and prevent you from exiting the program
without saving any work that you might have created. If you have
ever lost hours of work because you did not save properly, you will appreciate
such a feature.

At Berkner High School we want to keep the Turbo C++ IDE the same for
everybody. There are many options to customize the IDE. You can
change colors, change font size and give special boot-up instructions.
Such special options are stored in several files that Turbo C++ looks at during start
up time. We have locked these files to prevent them from being altered. This
way students can customize their IDE, do their thing, and when the bell
rings and they lack the time to change everything back, not to worry. Exit
Turbo C++ and the next person will start fresh. Turbo C++ will attempt to
save current settings. It is possible that you get an error message such as the
one shown below.

 File Edit Search Run Compile Debug Project Options Window Help
╔══[]═══════════════════════════ \PRACTICE.CPP ═══════════════════════1═[]═╗
║The quick brown fox jumps over the lazy dog. ║
║Now is the time for all good students to learn C++. ║
║This text editor has features that were originally ║
║developed for the popular Wordstar editor back in ║
║the early eighties. ║
║ ╔════════════════ Error ═══════════════╗ ║
║Do not be surprise║ ║ ║
║highlighted. Turb║ Can't create ║ ║
║ ║ ║ ║
║ ║ D:\TC30\BIN\TCDEF.DSK ║ ║
║ ║ ║ ║
║ ║ ║ ║
║ ║ ┌──────┐ ║ ║
║ ║ │ OK │ ║ ║
║ ║ └──────┘ ║ ║
║ ║ ║ ║
║ ╚══════════════════════════════════════╝ ║
║ ║
║ ║
║ ║
║ ║
║ ║
╚═════════9:1════════════════════════════════════════════════════════════════╝
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu

Ignore the error message. Press <Enter> to continue and exit or click on
the OK button and you are on your way.

Floppy Diskette Warning


Please, please, please leave Turbo C++ with a
disk in Drive A.

Chapter III The Turbo C++ IDE 3.17


DOS is not happy when you exit without a disk in drive A.
You take your disk. You leave the computer lab and now
the next student has misery. Usually, the next student needs
to reboot the computer because the computer is giving a tizzy
fit about having a disk where it was removed in an untimely
manner. So be kind and make life simpler for your fellow
students. Exit Turbo in a proper manner and leave the computer
either at the DOS prompt, or in Windows or in whichever state
your teacher tells you the leave the computer.

Loading an Existing Program

You did not realize this but it is now the next day.
Time just flies in the computer lab.

We now have a different situation. This time you are not creating a text
file from scratch. You want to continue with the file that you created
yesterday. Remember, the one saved as PRACTICE.CPP. Let us see if
you can load that file correctly.

Put your diskette in drive A and get into Turbo C++. Make sure your
diskette is the one that contains the file you saved. This is no problem
with the exercise we are running. You did not go anywhere and neither
did your diskette. However, very soon you will be going from lab to class,
to your locker, to home and back again. There will be many opportunities
to switch diskettes, to forget diskettes and in general not to be prepared.

Open the File menu with <Alt-F> or by clicking on the File name.
Remember, you must always change to the proper drive and/or directory
where your files are located. Press C for Change dir or click on Change.
In the Directory Name box type A:\ or other appropriate directory.

Press the <F3> key to open the "Open a File" window or click on File,
followed by a click on Open. You now have two options. You can actually
type the name of your file in the Name box, where the cursor is waiting or you
can select one of the files in the Files window below. Personally, I think it is
a good habit to select from available files.

You do not always remember what you called a file, and you also have the
opportunity to make typing errors.

Unless you specify something different, you will notice that the Name
window displays an *.CPP file name. This is the default action and the
Chapter III The Turbo C++ IDE 3.18
files displayed in the lower Files window all end with extension .CPP. Let
us assume that your file does have the usual .CPP ending.

Press the <Tab> key. The cursor will jump from the Name window to the
Files window and highlight the first file name. You can use arrow keys
to highlight the desired file and press <Enter> to load the file in memory
and show it in your edit window. Mouse users can double-click on the file
name to achieve the same result.

Sometimes students see nothing on the screen. The file name is correct at
the top of the edit window, but the file is empty. Usually, students will
swear to everything that is holy that they did write the required
information, they did save it properly and now the file is empty. This is
quite normal for beginning students. Most teachers, including myself, have
few answers for such occurrences. New students have unique skills that
they lose rapidly. These unique skills include the ability to make the
computer perform in a manner that no experienced computer person can
duplicate. Whatever, mysterious actions are performed by students it is
always done away from the teacher's eye. The evidence of the wrong
action is apparent, but the actions are the mystery. Usually, the best advice
is to repeat the correct steps. In most cases, you will get the desired result
on the second try.

3.6 Working With Blocks

There sure are bunches of ways to work with text blocks. In word processing lingo
this usually means "cutting and pasting." This skill is vital for efficient program
writing. You will frequently encounter situations where it is very desirable to copy a
section of code that needs to be repeated elsewhere. It is also possible that you have
a correct program segment, but it is in the wrong location and it needs to be moved.
There are many reasons, and there are many ways to perform these important
actions.

Key stroke people, start by remembering the following:

All block commands use a double key stroke starting with K

The second letter of the keystroke indicates the nature of the block command, and
this letter is a logical letter in most cases. Consider the following (incomplete) set of
block commands:

<Ctrl-KB> Mark the Beginning of a block


<Ctrl-KK> Mark the end of a blocK (note K ends the word block)
Chapter III The Turbo C++ IDE 3.19
<Ctrl-KC> Copies a block

Copy/Cut and Paste a Block

Place the cursor at the top-left corner of your text file.

Press <Ctrl-KB> to mark the beginning of the block. Make sure that you
press the <Ctrl> key first. Nothing will happen as a result of this first
action.

Move the cursor down four lines.


Press <Ctrl-KK> to mark the end of the block.
The lines above the cursor to the starting location should be highlighted.
You now have a genuine block.

Move the cursor down a few more lines.


Copy the block with <Ctrl-KC>.
You will see a copy of the block at the new location.

You will also notice that the new block is highlighted.


Press <Ctrl-KH> to hide (remove highlighting) the block.

You just performed a "Copy and Paste".

Now let us do a similar action to perform a "Cut and Paste".


This time let us mark the block in a different, and probably nicer way.
Place the cursor at the starting location of the block.
Press the <Shift> key and hold it down.
Move the <Down Arrow> key until you reach the end of the block.
You will see the block form in front of your eyes.
Move the cursor to the new block location. It matters little where.
Press <Ctrl-KV> to moVe the block to the new location.

The mice people are getting anxious. You sense a distinct prejudice here.
Why are the keystrokes always mentioned first and the mouse actions
shown last? The answer is simple. Mr. Schram wrote this book - and
quite weird, he sometimes writes about himself in the third person - and
he prefers keystrokes and therefore mentions them first. However, the mice
people are not ignored, but they do come second. Anybody, who does not
like this approach is cordially invited to write his or her own book and
explain mouse business first.

Perhaps many mice people will argue that the use of the mouse is so
intuitive that little explanation is necessary. The keystrokes on the other
hand, are not exactly so easy to learn without instruction.

Chapter III The Turbo C++ IDE 3.20


Marking a block with a mouse follows the standard "click and drag"
approach. Place the mouse cursor at the start of the block and click. Now
hold down the left button and drag to the end of the block. You will see
the block forming in front of your eyes. Release the left button when the
end of the block has been reached.

Now open up the Edit window and click on Copy.


Move the mouse cursor to the copy location and click.
Open up the Edit window again and click on Paste.

Cut and Paste is almost the same. The only difference is that you click
on the Cut command, rather than the Copy command.

Hiding (remove the highlighting) a block with a mouse is done by clicking


the left button once. The mouse can be anywhere to achieve this action.

Deleting a Block

You can delete a block with <Ctrl-KY>. The only way I can easily
remember this is that Y stands for Yank. The command is consistent.
You delete a line with <Ctrl-Y> and an entire block with <Ctrl-KY>.

With the mouse you need to open the Edit window and click on the Clear
command.

3.7 Finding The Proper Directory

Turbo C++ is very particular about the "current" or "default" directory. You will
realize later why this is so important. Earlier in this chapter we changed the current
directory to A:\. This was nice and simple, but frequently directories can be deep
inside a complex directory tree structure. The Turbo IDE gives you several options
to help you navigate to the right location. Imagine that you have opened the
Change Directory window and it looks like the one below.

 File Edit Search Run Compile Debug Project Options Window Help
╔══[]═════════════════════ D:TC30\BIN\NONAME00.CPP ═══════════════════1═[]═╗
║ ║
║ ║
Chapter III The Turbo C++ IDE 3.21
║ ╔═══════════ Change Directory ════════════════╗ ║
║ ║ ║ ║
║ ║ Directory Name ║ ║
║ ║ ┌───────────────────────────┐ ║ ║
║ ║ │ C:\ │ ║ ║
║ ║ └───────────────────────────┘ ║ ║
║ ║ ┌────────┐ ║ ║
║ ║ Directory Tree │ OK │ ║ ║
║ ║ ┌──────────────────────────┐ └────────┘ ║ ║
║ ║ │ Drives │ ║ ║
║ ║ │ C:\ │ ┌────────┐ ║ ║
║ ║ │ └┬─CDROM │ │ Chdir │ ║ ║
║ ║ │ ├─DOS │ └────────┘ ║ ║
║ ║ │ ├─DRIVERS │ ║ ║
║ ║ │ ├─NAV │ ┌────────┐ ║ ║
║ ║ │ ├─NCDTREE │ │ Revert │ ║ ║
║ ║ │ ├─NWCLIENT │ └────────┘ ║ ║
║ ║ │ ├─PLUGPLAY │ ║ ║
║ ║ └────┴─────────────────────┘ ┌────────┐ ║ ║
║ ║ │ Help │ ║ ║
║ ║ └────────┘ ║ ║
║ ╚═════════════════════════════════════════════╝ ║
║ ║
╚═══════ 1:1 ════════════════════════════════════════════════════════════════╝
F1 Help │ Use cursor keys to navigate through directory tree

If you know the precise path, from root to final subdirectory, you can type that in the
Directory Name box. But for now let us assume that you do not know the exact
path. For starters assume that you are not even in the correct drive. We want to
change to drive E:\.

Type E:\ in the Directory Name box and press the <Tab> key. Do not press
<Enter>. Pressing <Enter> will change the current drive to E:\, but it will also
close the window and assume you are done. When you press the <Tab> key the
Directory Tree window changes and appears like the one shown on the next page.
To save space, only the Change Directory window is shown. Imagine that the
window fits inside the larger Turbo C++ IDE window.

╔═[]═══════ Change Directory ════════════════╗


║ ║
║ Directory Name ║
║ ┌──────────────────────────┬─┐ ║
║ │ E:\ ││ ║
║ └──────────────────────────┴─┘ ║
║ ┌────────┐ ║
║ Directory Tree │ OK │ ║
║ ┌──────────────────────────┐ └────────┘ ║
║ │ Drives │ ║
║ │ E:\ │ ┌────────┐ ║
║ │ └┬─A80QUIZ │ │ Chdir │ ║
║ │ ├─AB80QUIZ │ └────────┘ ║
║ │ ├─ACDEC6 │ ║
║ │ ├─ADMIN │ ┌────────┐ ║
║ │ ├─AGENDAS │ │ Revert │ ║
║ │ ├─AP1ASN │ └────────┘ ║
║ │ ├─AP1PROGS │ ║
║ └────┴─────────────────────┘ ┌────────┐ ║
Chapter III The Turbo C++ IDE 3.22
║ │ Help │ ║
║ └────────┘ ║
╚═════════════════════════════════════════════╝

In this case I am trying to find some CPP files that I am using for some assignment.
The directory is not always alphabetized, as it appears. I need to use the arrow keys
to see the rest of the selections. I stop when I see BOOKS. My files are located
somewhere in there. The window now looks as follows:

╔═[]═══════ Change Directory ════════════════╗


║ ║
║ Directory Name ║
║ ┌──────────────────────────┬─┐ ║
║ │ E:\ ││ ║
║ └──────────────────────────┴─┘ ║
║ ┌────────┐ ║
║ Directory Tree │ OK │ ║
║ ┌────┬─────────────────────┐ └────────┘ ║
║ │ ├─AP2PROGS │ ║
║ │ ├─APCLASS │ ┌────────┐ ║
║ │ ├─APEXAMS │ │ Chdir │ ║
║ │ ├─APMCTEST │ └────────┘ ║
║ │ ├─APSTUFF │ ║
║ │ ├─BHSPRBHS │ ┌────────┐ ║
║ │ ├─INHERIT │ │ Revert │ ║
║ │ ├─BINTREE │ └────────┘ ║
║ │ ├─BOOKS │ ║
║ └────┴─────────────────────┘ ┌────────┐ ║
║ │ Help │ ║
║ └────────┘ ║
╚═════════════════════════════════════════════╝

I am looking at a sequence of subdirectories, and I know my files are located inside


the BOOKS subdirectory. I highlight the BOOKS subdirectory and press <Enter>
to change to the next level of subdirectories. Keep in mind that in this window you
will only see subdirectories. Individual files will not be shown. The window
changes and shows yet another level of subdirectories. You will see that all the
subdirectories at the same level as BOOKS are gone.

╔═[]═══════ Change Directory ════════════════╗


║ ║
║ Directory Name ║
║ ┌──────────────────────────┬─┐ ║
║ │ E:\BOOKS ││ ║
║ └──────────────────────────┴─┘ ║
║ ┌────────┐ ║
║ Directory Tree │ OK │ ║
║ ┌──────────────────────────┐ └────────┘ ║
║ │ Drives │ ║
║ │ E:\ │ ┌────────┐ ║
║ │ └─┬BOOKS │ │ Chdir │ ║
║ │ ├─PASCAL1 │ └────────┘ ║
║ │ ├─PASCAL2 │ ║
║ │ ├─VGAGFX.PAS │ ┌────────┐ ║

Chapter III The Turbo C++ IDE 3.23


║ │ ├─VGAGFX.CPP │ │ Revert │ ║
║ │ ├─PASCAL.OVH │ └────────┘ ║
║ │ ├─VGABOOK.PAS │ ║
║ └─────┴────────────────────┘ ┌────────┐ ║
║ │ Help │ ║
║ └────────┘ ║
╚═════════════════════════════════════════════╝

As before I need to scroll down to get to the desired subdirectory, which in this case
is SF-BOOK1.CPP, and then press <Enter>.

╔═[]═══════ Change Directory ════════════════╗


║ ║
║ Director Name ║
║ ┌──────────────────────────┬─┐ ║
║ │ E:\BOOKS ││ ║
║ └──────────────────────────┴─┘ ║
║ ┌────────┐ ║
║ Directory Tree │ OK │ ║
║ ┌───┬──────────────────────┐ └────────┘ ║
║ │ └─┬BOOKS │ ║
║ │ └┬─PASCAL1 │ ┌────────┐ ║
║ │ ├─PASCAL2 │ │ Chdir │ ║
║ │ ├─VGAGFX.PAS │ └────────┘ ║
║ │ ├─VGAGFX.CPP │ ║
║ │ ├─PASCAL.OVH │ ┌────────┐ ║
║ │ ├─VGABOOK.PAS │ │ Revert │ ║
║ │ ├─VGABOOK.CPP │ └────────┘ ║
║ │ ├─SF-BOOK1.CPP │ ║
║ └──────┴───────────────────┘ ┌────────┐ ║
║ │ Help │ ║
║ └────────┘ ║
╚═════════════════════════════════════════════╝

There seems to be no end to these subdirectories, because we have not reached the
end yet. There are more subdirectories at the lower level, which are shown below.

╔═[]═══════ Change Directory ════════════════╗


║ ║
║ Directory Name ║
║ ┌──────────────────────────┬─┐ ║
║ │ E:\BOOKS\SF-BOOK1.CPP ││ ║
║ └──────────────────────────┴─┘ ║
║ ┌────────┐ ║
║ Directory Tree │ OK │ ║
║ ┌───┬──────────────────────┐ └────────┘ ║
║ │ └─┬BOOKS │ ║
║ │ └─┬SF-BOOK1.CPP │ ┌────────┐ ║
║ │ └┬─DEMOS1.CPP │ │ Chdir │ ║
║ │ └─BOOK1.CPP │ └────────┘ ║
║ │ │ ║
║ │ │ ┌────────┐ ║
║ │ │ │ Revert │ ║
║ │ │ └────────┘ ║
║ │ │ ║
║ └──────────────────────────┘ ┌────────┐ ║
║ │ Help │ ║

Chapter III The Turbo C++ IDE 3.24


║ └────────┘ ║
╚═════════════════════════════════════════════╝

Highlight DEMOS1.CPP and press <Enter>. What a surprise, there are more
subdirectories. You may think that this is a phony demonstration, but in fact, a real
hard drive was used. You are looking at the subdirectories of the hard drive that I
used when I first wrote this chapter. This is a realistic example and helps to explain
why it is not always easy to type in the entire path from root to final subdirectory.

╔═[]═══════ Change Directory ════════════════╗


║ ║
║ Directory Name ║
║ ┌──────────────────────────┬─┐ ║
║ │E:\BOOKS\SF-BOOK1.CPP\DEM ││ ║
║ └──────────────────────────┴─┘ ║
║ ┌────────┐ ║
║ Directory Tree │ OK │ ║
║ ┌──────────────────────────┐ └────────┘ ║
║ │ Drives │ ║
║ │ └─┬E:\ │ ┌────────┐ ║
║ │ └─┬Books │ │ Chdir │ ║
║ │ └─┬SF-BOOK1.CPP │ └────────┘ ║
║ │ └─┬DEMOS1.CPP │ ║
║ │ ├──INTRODUC.C0 │ ┌────────┐ ║
║ │ ├──BASICS.C02 │ │ Revert │ ║
║ │ ├──MOREBASC.C0 │ └────────┘ ║
║ │ ├──PRINTER.C04 │ ║
║ └───────────┴──────────────┘ ┌────────┐ ║
║ │ Help │ ║
║ └────────┘ ║
╚═════════════════════════════════════════════╝
Finally, the end is here. The long awaited subdirectory, MOREBASC.C03, has
been found. Highlight that subdirectory and press enter. You will notice that
nothing appears below MOREBASC.C03. This indicates that it is the final
subdirectory. Only files will now show up and that is done at another location.

╔═[]═══════ Change Directory ════════════════╗


║ ║
║ Directory Name ║
║ ┌──────────────────────────┬─┐ ║
║ │ E:\BOOKS\SF-BOOK1.CPP\DE ││ ║
║ └──────────────────────────┴─┘ ║
║ ┌────────┐ ║
║ Directory Tree │ OK │ ║
║ ┌─── ──────────────────────┐ └────────┘ ║
║ │ Drives │ ║
║ │ └─┬E:\ │ ┌────────┐ ║
║ │ └─┬Books │ │ Chdir │ ║
║ │ └─┬SF-BOOK1.CPP │ └────────┘ ║
║ │ └─┬DEMOS1.CPP │ ║
║ │ └──MOREBASC.C0 │ ┌────────┐ ║
║ │ │ │ Revert │ ║
║ │ │ └────────┘ ║
║ │ │ ║
║ └──────────────────────────┘ ┌────────┐ ║
Chapter III The Turbo C++ IDE 3.25
║ │ Help │ ║
║ └────────┘ ║
╚═════════════════════════════════════════════╝

Using the Mouse to Change Directories

We will go through the same steps, but now use a mouse. It will not be
necessary to show most of the windows. They are identical after the
change to the new drive.

Many people prefer to use a mouse for this changing directory business.
It can be confusing without a mouse. There are times when you use
<Tab>, there are times when you need to move <Arrow keys>, and there
are times when you press <Enter>. Do you know which one?

Here are the mouse steps to get to the same subdirectory, which by the way has the
following path:

E:\BOOKS\SF-BOOKS1.CPP\DEMOS1.CPP\MOREBASC.C03\

Click on File and Change dir to open the Change Directory Window

Double-click on Drives to allow a new drive selection.

╔═[]═══════ Change Directory ════════════════╗


║ ║
║ Directory Name ║
║ ┌──────────────────────────┬─┐ ║
║ │ C:\ ││ ║
║ └──────────────────────────┴─┘ ║
║ ┌────────┐ ║
║ Directory Tree │ OK │ ║
║ ┌──────────────────────────┐ └────────┘ ║
║ │ Drives │ ║
║ │ └─┬─A │ ┌────────┐ ║
║ │ ├─B │ │ Chdir │ ║
║ │ ├─C │ └────────┘ ║
║ │ ├─D │ ║
║ │ ├─E │ ┌────────┐ ║
║ │ └─F │ │ Revert │ ║
║ │ │ └────────┘ ║
║ │ │ ║
Chapter III The Turbo C++ IDE 3.26
║ └──────────────────────────┘ ┌────────┐ ║
║ │ Help │ ║
║ └────────┘ ║
╚═════════════════════════════════════════════╝

Now double-click on E: and you have the same menu that was shown
earlier with the key stroke method.

Click on the down arrow at the bottom-right corner of the Directory Tree
window to scroll the directories upward until Books appears.

Double-click on Books to move to the next subdirectory level.

Click on the down arrow and scroll until SF-BOOK1.CPP appears.

Double-click on SF-BOOK1.CPP to move to the next subdirectory.

Double-click on DEMOS1.CPP to move to the next subdirectory.

Double-click on MOREBASC.C03 to move to the final subdirectory.

Click on the OK button accept and exit the Change Directory Window.

Loading an Existing File from a Subdirectory

Press the <F3> key and the Open a File window opens up. The normal
default are files with *.CPP extensions and those will be the only files
shown. You will see something like:

╔══[]══════════════ Open a File═════════════════╗


║ ║
║ Name ║
║ ┌───────────────────────────┬─┐ ┌─────────┐ ║
║ │ *.CPP ││ │ Open │ ║
║ └───────────────────────────┴─┘ └─────────┘ ║
║ ║
║ Files ║
║ ┌──────────────┬──────────────┐ ┌─────────┐ ║
║ │ MORE01.CPP │ MORE09.CP │ │ Replace │ ║
║ │ MORE02.CPP │ MORE10.CPP │ └─────────┘ ║
║ │ MORE03.CPP │ MORE11.CPP │ ║
║ │ MORE04.CPP │ ..\ │ ┌─────────┐ ║
║ │ MORE05.CPP │ │ │ Cancel │ ║
║ │ MORE06.CPP │ │ └─────────┘ ║
║ │ MORE07.CPP │ │ ║
║ │ MORE08.CPP │ │ ┌─────────┐ ║
║ │ │ │ │ Help │ ║
║ └─────────────────────────────┘ └─────────┘ ║
║ ║
╟────────────────────────────────────────────────╢
║ E:\BOOKS\SF-BOOK1.CPP\DEMOS1.CPP\MOREBASC.C03\ ║
║ MORE01.CPP 610 May 25, 1996 3:34pm ║
Chapter III The Turbo C++ IDE 3.27
╚════════════════════════════════════════════════╝

If the file you need shows in the Files window, use the arrow keys to
highlight the desired file and press <Enter>. This will load the file in the
edit window.

You can also double-click on the file name to load the file in the edit
window. Perhaps you are a single-click kind of person. That works too.
Single-click on a file name to select the file, and then single-click on the
Open button to load the file in the edit window.

Frankly, I am not sure why the Open button exists. You do not need it for
the key stroke method, and you do not need it for the mouse method.
However, it is good for impressing friends if you want to show more steps
to do less work.

Finding Lost Files

Normally, your C++ files will have an .CPP extension, but at times that
is not the case. You may open up the file window and the desired file
does not appear. Not to worry. Change the *.CPP default in the Name
box to *.* and all the files at that location will show up. It will give this
type of appearance.

╔═[]═══════════════ Open a File═════════════════╗


║ ║
║ Name ║
║ ┌───────────────────────────┬─┐ ┌─────────┐ ║
║ │ *.* ││ │ Open │ ║
║ └───────────────────────────┴─┘ └─────────┘ ║
║ ║
║ Files ║
║ ┌──────────────┬──────────────┐ ┌─────────┐ ║
║ │ MORE01.C │ MORE03.PAS │ │ Replace │ ║
║ │ MORE01.CPP │ MORE04.C │ └─────────┘ ║
║ │ MORE01.PAS │ MORE04.CPP │ ║
║ │ MORE02.C │ MORE04.PAS │ ┌─────────┐ ║
║ │ MORE02.CPP │ MORE05.C │ │ Cancel │ ║
║ │ MORE02.PAS │ MORE05.CPP │ └─────────┘ ║
║ │ MORE03.C │ MORE05.PAS │ ║
║ │ MORE03.CPP │ MORE06.C │ ┌─────────┐ ║
║ │ │ │ │ Help │ ║
║ └─────────────────────────────┘ └─────────┘ ║
║ ║
╟────────────────────────────────────────────────╢
║ E:\BOOKS\SF-BOOK1.CPP\DEMOS1.CPP\MOREBASC.C03\ ║
║ MORE01.CPP 610 May 25, 1996 3:34pm ║

Chapter III The Turbo C++ IDE 3.28


╚════════════════════════════════════════════════╝

What if your file still does not show up? Well, there are two possibilities. One, you
are in the wrong subdirectory, and you need to search elsewhere. Two, you did not
save your file, or at least you did not save it with a name that you are able to
recognize.

One final warning for this section. It is tempting to load a file by skipping the
Change Directory Stage. You could type something like:

E:\DATAFILE\LABEXR01.CPP

That method may work, at least it may work in the beginning, but please listen
carefully. Never, never, never, type any directory path in the Name box of the Open
a File window. It will give you headaches.

3.8 Running A Small C++ Program

Everything shown up to this point has revolved around using the Turbo IDE for
editing and filing purposes. Nothing has required writing, compiling, or running any
type of program. In this section we will write a small program. No attempt will be
made to explain any of the C++ program logic or requirements. The main purpose
of this section is to show you the steps necessary to edit, save, compile and run a
program. Many of the previous sections have been unrelated. We will now take
you through a complete program sequence by the numbers. We will assume that
you are at a DOS prompt or in a Windows environment.

[01] Get into the Turbo IDE.


[02] Insert a floppy diskette in drive A: and change directory to A:
[03] Type the following program in the edit window.
Make sure to use lower case, where lower case is shown.

#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();
cout << "THIS IS YOUR FIRST PROGRAM" << endl;
cout << endl;
cout << "PRESS <ENTER> TO RETURN TO TURBO" << endl;
Chapter III The Turbo C++ IDE 3.29
getch();
}

[04] Save the file as FIRST.CPP. Have patience with the computer. You may
have a fast computer, but file operations with a floppy diskette are
notoriously slow.

[05] Compile the program with <F9>. A Compiling window will show on the
center of the screen. At the bottom of the window it should say Success
and Press any key should be blinking. It is also possible that the window
says Errors at the bottom. Go ahead and press the space bar. An
error message window will show up and other weird stuff will happen. Press the
<F6> key to return to normal editing. Toggle the <F5> key to maximize the
edit window. Check your text carefully. Something was not copied
correctly.
[06] If your program compiles correctly, you are ready to run the program and
see the output. Press <Ctrl-F9>. The program will go through the same
steps as compiling earlier, and then you should see the following message
on the screen.

┌──────────────────────────────────────────────┐
│THIS IS YOUR FIRST PROGRAM │
│ │
│PRESS <ENTER> TO RETURN TO TURBO │
│ │
└──────────────────────────────────────────────┘
IMPORTANT NOTE:

It may be that you have done everything correctly and the program does
not work correctly. There are a variety of Turbo C++ files that have to be
found. It is possible that the Turbo IDE needs to be altered slightly to
indicate where those files are.

Sounds confusing? It is, and the point is that you probably need to call
your teacher or somebody with greater knowledge to check what is wrong.
At this stage, you can only check a careful line by line comparison to
make sure that you copied the files correctly.

3.9 Working With Multiple Files


Chapter III The Turbo C++ IDE 3.30
A few weeks or maybe a few months from now you will frequently find it useful to
take a program segment from one file and use it in another file. This type of
requirement calls for working with several files at the same time. It is also possible
that you are participating in a lab lecture where multiple files need to be used.
Frequently, your teacher may suggest to open up two windows to compare the code
of two different programs.

For this exercise start by writing two separate files with names FILE1.CPP and
FILE2.CPP. Write each file and save it when you are done. Create the following
files.

┌─────────────────────────────────────────────────────┐
│This is File1.CPP │
│Kathy Coleman │
│1234 Main Street │
│Dallas, Texas 75240 │
│ │
└─────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────┐
│This is File2.CPP │
│Tom Terrific │
│4321 Elm Street │
│Richardson, Texas 75080 │
│ │
└─────────────────────────────────────────────────────┘
After the two files are created, and saved, exit Turbo with <Alt-X>. This is done to
make sure that everybody has the same screen appearance.

Turbo C++ can deal with many files simultaneously. For now we only want to work
with the two files that you have just created. Load FILE1.CPP in the edit window,
and then load FILE2.CPP. You should get the following screen result.

 File Edit Search Run Compile Debug Project Options Window Help
┌───────────────────────────────── \FILE1.CPP ─────────────────────────1─────┐
│╔═══════════════════════════════ \FILE2.CPP ═════════════════════════2═[]══╗
│║This is File 2 ║
│║Tom Terrific ║
│║4321 Elm Street ║
│║Richardson, Texas 75080 ║
│║ ║
│║ ║
│║ ║
│║ ║
│║ ║
│║ ║
│║ ║

Chapter III The Turbo C++ IDE 3.31


│║ ║
│║ ║
│║ ║
│║ ║
│║ ║
│║ ║
│║ ║
│║ ║
│║ ║
│║ ║
└╚════════5:1════════════════════════════════════════════════════════════════╝
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu

Now your two edit windows are cascaded. You can tell there are two files because
each file has a number, you can see both file names, and you see two file borders on
the screen. However, copying blocks between the two files is not very practical. The
easiest way to change between the two screens is by toggling the <F6> key. Open
up the Window window with <Alt-W> or click on Window.

Press T for Tile or click on the Tile command. You will now have two windows
side by side for viewing, and block copying convenience. The appearance is like the
example on the next page.

 File Edit Search Run Compile Debug Project Options Window Help
┌────────────────────────────────────────────────────────────────────────────┐
│┌──────────── \FILE2.CPP ───────2─────┐╔═[]═══════ \FILE1.CPP ═════1═[]═╗│
││This is File 2 │║This is File 1 ║│
││Tom Terrific │║Kathy Coleman ║│
││4321 Elm Street │║1234 Main Street ║│
││Richardson, Texas 75080 │║Dallas, Texas 75240 ║│
││ │║ ║│
││ │║ ║│
││ │║ ║│
││ │║ ║│
││ │║ ║│
││ │║ ║│
││ │║ ║│
││ │║ ║│
││ │║ ║│
│└─────────────────────────────────────┘╚═══════════════════════════════════╝│
└────────────────────────────────────────────────────────────────────────────┘
F1 Help F2 Save F3 Open Alt-F9 Compile F9 Make F10 Menu

You will notice that one of the screens - FILE1.CPP - is highlighted. The file name
is in bold, the edit window has a double-line border.
Chapter III The Turbo C++ IDE 3.32
You can toggle between the two screen by repeatedly pressing the <F6> key. You
will notice that the highlighting switches. With the mouse you can click anywhere
in the "non-highlighted" screen to make it the current edit screen.

Working with a larger edit window is easy without losing the second file.
Press the <F5> key any you will see the current file maximize to the entire screen.
Press the <F5> a second time and you are back in the Tile display.

With a mouse you can click on the up-arrow in the current screen, which will
maximize the screen. Clicking on the up/down-arrow will minimize the screen
back to Tile display.
Now we will copy Tom Terrific's address to FILE1.CPP.

Make FILE2.CPP the current file by toggling <F6> or clicking.

Highlight the block of two lines that contains:

4321 Elm Street


Richardson, Texas 75080

Please be aware that the copy (<Ctrl-KC>) and the move (<Ctrl-KV>) shortcut
commands are block commands that only work within a file. You will need to use
the Edit window to copy between files.

Open the Edit window with <Alt-E> or click on Edit.

Press C for Copy or click on the Copy command.


Switch to FILE1.CPP with <F6> or click in the FILE1.CPP window.

Move the cursor below Kathy Coleman.

Open the Edit window with <Alt-E> or click on Edit.

Press P to Paste the block or click on Paste.

You block has now been copied.

You can use similar logic to "cut and paste" a block.

3.10 Using Hot Keys


By now you have noticed that there is a pretty good supply of shortcuts that allow
actions to be performed with a single key stroke. It is difficult to beat pressing <F2>
to save a file. The single function key shortcuts can beat any other method,
Chapter III The Turbo C++ IDE 3.33
including a good mouse handler. Double key strokes are optional. Personally, I
tend to use all the single "hot keys" and uses the mouse for a variety of other
changes, like changing directories and cutting and pasting between files.
Once again the choice is yours. The intelligent thing to do is pick the method that
works best for you. Normally, the same method is not best for all situations.

In this section we will not list all the hot keys commands. It is lovely to supply you
with a complete list, but this book is meant to teach as a tutorial and not be a
reference guide. You will see many, many key strokes on the Turbo IDE that were
not explained, and are not mentioned here. Remember, that this chapter will not
attempt to explain the entire Turbo IDE. You can satisfy any curiosity by
highlighting a command and reading the <F1> help window.

Single Stroke "Hot Key" Commands

<F1> Displays online help for Turbo IDE commands.

<F2> Saves the text file in the current Edit window.

<F3> Allows quick loading of a file from the Open a File window

<F5> Toggles between Maximized and minimized edit windows.

<F6> Toggles between the different file and message windows.

<F10> Jumps IDE control to the Main Selection Menu Bar.


Compile/Run Commands

<Alt-F9> Compiles the current edit window file, regardless of existing


code files.

<F9> Compiles your program into an *.EXE file. <F9> will not
compile a program if a current compiled file exists.

<Ctrl-F9> Compiles your program into an *.EXE file, if no current *.EXE


file exists, and then executes the program.

Jump to Windows "Hot Key" Commands

<Alt-F> Opens the File window

<Alt-E> Opens the Edit window

Chapter III The Turbo C++ IDE 3.34


<Alt-S> Opens the Search window

<Alt-R> Opens the Run window

<Alt-C> Opens the Compile window

<Alt-D> Opens the Debug window

<Alt-P> Opens the Project window

<Alt-O> Opens the Options window

<Alt-W> Opens the Window window

<Alt-H> Opens the Help window

<Alt-X> Exits the Turbo IDE

Block Commands

<Ctrl-KB> Marks the beginning of a Block

<Ctrl-KK> Marks the end of a blocK

<Ctrl-KC> Copies a block to current cursor position

<Ctrl-KV> MoVes a block to current cursor position

<Ctrl-KY> Deletes (Yanks) a block from the edit window

<Ctrl-KR> Reads a block from an external file

<Ctrl-KW> Writes a block to an external file

<Ctrl-KH> Hides the current highlighted block

<Ctrl-KP> Prints the block to the current printer

Chapter III The Turbo C++ IDE 3.35


The list of "hot keys" that we just provided is probably quite adequate for this
stage. It already includes a variety of commands that you will not use until later on
in the course.

There are also many other key strokes, that you will see on the Turbo IDE that have
not been mentioned. Again, remember, this book is meant to be a practical learning
guide for you, not a complete reference manual.

3.11 Different Turbo C++ Memory Models

There is one important topic that is difficult to insert in this book. It is the type of
thing that should belong in an appendix. My concern is that you may get into
trouble and not think of looking for answers in some obscure appendix. Read the
section that follows, and try the exercise. Try not to figure out what is going on.
This section is here to make you aware of an important feature that may be needed
some time in the future. When it happens, hopefully a light bulb will go up and you
will jump back to this section.

Do you have a clue what is going on? Of course not, absolutely nothing has been
explained. This is part of the student friendly approach. Tell somebody nothing and
they will not be confused. Student friendly or not, a brief explanation will be
attempted to trigger your memory for later needs.

Proper memory management is a major problem for program compilers like C++.
Different parts of the program require different chunks of a small, finite quantity of
memory. If the wrong amount of memory is allocated to some program feature
called a stack, you may find that your program will crash. Now keep in mind that
nothing is wrong with your program. You did your job, but your program cannot
function without the proper memory allocations. The understanding of these
different memory needs is way beyond the scope of the current chapter. However,
try the following analogy. Imagine that 250 students need to fit in 10 classrooms,
which each holding 30 desks. At first glance, everything seems fine and there
should be no problem. But there is a problem because 100 students are part of the
band and need a classroom large enough to hold all 100 students at once. In this
case the school space is not allocated properly.

Turbo C++ has six different memory models called:

Tiny Small Medium Compact Large Huge

Chapter III The Turbo C++ IDE 3.36


Usually, the installation program will select the Small memory model for normal
operations. This is fine in the beginning, but may not be sufficient for later
requirements. In this section, you need to learn how to change the memory model.
Later on , you will understand better why you need to change.

Open the Options window with <Ctrl-O> or click on Options.

Press C to open the Compiler window or click on Compiler.

Press C to select Code generation or click on Code generation.

Use the <Tab> key to move around the Code generation window, and the <arrow>
keys to move up and down the memory Model selection box. Stop at the desired
memory model and <Tab> to the <OK> button and press <Enter>. Mouse folks
have an easier job here. Click on the desired memory model and on <OK> and you
are done.

The computer lab you are using may be set up to prevent permanent changes of
certain file configurations. If that is the case you may need to make this change
whenever it is needed. If your computer does not have file configuration protection,
you will have the same memory model for future use.
3.12 The Turbo C++ Selection Menu

We will finish this chapter with a brief overview of the different selections on the
Main Turbo Selection Menu Bar. This is not an explanation on how to use
various features, but rather an awareness of some of the available options. The
selections will be listed from left to right, as they appear on the menu bar.

File Window

Used for file operations such as:


Start a new file
Open an existing file
Save a current file
Change current directory
Print a file
Shell out to the DOS prompt
Quit the Turbo IDE

Edit Window
Chapter III The Turbo C++ IDE 3.37
Used for editing features such as:
Undo latest editing command
Cut and paste a text block
Copy and paste a text block
Delete a text block

Search Window

Used for search operations like:


Find a specified string
Find and replace a string

Run Window

Used to:
Run entire program in the edit window
Trace through a program execution
Run part of a program
Compile Window

Used to:
Compile the program in the edit window
Create a DOS *.EXE program file
Link different programs together
Provide information statistics about a program

Debug Window

Allows a variety of techniques, which assist in debugging a program.

Project Window

Allows organized program development of large programs by placing all the


necessary files for the program in one convenient unit, called a project.

Options Window

Allows a large variety of Turbo IDE custom features such as:


Compiler options, especially specifying the model size
There are many advanced programming options
Specify the location of the header files and libraries
Chapter III The Turbo C++ IDE 3.38
Change colors and size of the Turbo Environment

Window Window

Makes various changes to the edit window(s) display such as:


Maximize and minimize the current window
Tile or cascade multiple windows
Switch between different windows
Close all the windows in memory
Watch the output user screen

Help Window

Gives online help on a wide variety of selected topics

3.13 Turbo C++ 3.0 and Standard C++

I think that the Turbo C++ for DOS, version 3.0 is absolutely wonderful for teaching
computer science to introductory students. The integrated development environment
is the simplest around and students require minimum "start-up" time to learn how to
use the editor and compiler.

Another benefit is that it is very easy to load many program examples. You will find
that one teaching approach is to have you load one program example after another
into the editor, view it, run it and discuss it. This method is only practical if loading,
compiling and running can be accomplished with a minimum of difficulties. In this
area Turbo C++ 3.0 reigns supreme.

However, version 3.0 is an earlier and older version. This compiler was developed
before the C++ standard was even close to being finished. The result is certain later
features are not available and perhaps more troublesome, Turbo C++ lets you do a
few illegal maneuvers that should not be allowed in C++.

Now this is not a problem for the introductory student. The features in question do
not apply at all to anything students will encounter in the first semester and hardly
even during the first year. It is with advanced topics that the older compiler will not
be as beneficial as it was in the beginning. So do not be suprised if you need to learn
another compiler at some later date. For now this is mentioned for the benefits of
both teachers and students who look ahead, try certain things and find a few quirks
that do not add up properly.

Chapter III The Turbo C++ IDE 3.39


Turbo C++ Version 3.0 Quirks

Turbo C++, Version 3.0 is an older compiler developed before


the C++ standard was finalized.

Version 3.0 lacks various features adopted for the standard.

Version 3.0 also fails to catch various illegal C++ maneuvers.

Chapter III The Turbo C++ IDE 3.40

You might also like