CS1711 Lab - September 22 & 24, 1998

Navigating the IDE

Introduction

This first lab will introduce you to the IDE (Integrated Development Environment), explain how to compile and run programs and explain how to use the new NT lab as well as provide a reference source for the other PC labs on campus. The IDE is the program in which you write C++ programs. In some systems, there is no IDE and the programmer must write a programs using an editor, save the file, then type a command to compile the program. For those people who are using the RHIDE environment at home (the freeware compiler available from the website), just about every comment made about the Borland IDE will apply.

PEG Lab

The PEG lab uses a very different configuration from what you are probably use to. Each computer in the PEG lab uses Windows NT. When you are in this lab you will have to use the following steps to log in. I have provided a reference below as to how to access Turbo C++ from the other PC labs.
  1. If the computer you are sitting in front of has a blue screen containing some strange numbers and the computer is just sitting doing nothing, you will have to press the reset button (the button without the light in the center).
  2. Press Ctrl-Alt-Del and you will be given a prompt dialog. Enter your username, press Tab (not Enter), then type your password. Leave the Domain as MTA and click Ok. You should see a screen which looks very similar to Windows95.
  3. If you are in a lab session (as opposed to working on an assignment), you will have to connect one of your drives to the Departmental Area. Move the mouse over the 'My Computer' icon and press the right button. Select the menu item 'Map Network Drive'. Set the Drive letter to T (this will match the lab instructions). Fill in the path '\\home\deptfile' (without the quotes). Computing Services has promised that these steps will be automated in the near future.
  4. Click on the Start button and select PCLab then finally 'Turbo C++ 3.0'.
  5. After a few seconds you will see a copy of Turbo C++ running. You may press Alt-Enter to make the program run in full screen mode if you wish.
  6. Don't do these now! When you are finished with the lab, press the 'Start' button and select 'Shutdown...'. Then click on 'Close all programs and log in as a different user'. Do not get in the habit of simply pressing the power switch, this can cause your files to be erased!

Advard Dixon and Crabtree Labs

  1. Log into the Local Area Network (LAN) by giving your username and password.
  2. If you are working on a lab problem outside of the PEG lab, you will need to double click on 'Academic Programs' then double click on 'Connect Drive T to Departmental Files'.
  3. Open the folder named `Programming'.
  4. Double click on the icon named `Turbo C++ 3.0'. You will be asked if you want to use drive A, E, or M; most times you will probably want to use drive M. After a few seconds (or minutes if network activity is high) you will see a screen consisting of three components: the main menu, the status line, and the desktop.
  5. If you end up in a situation where pressing the arrow keys cause the window to slide around, you have probably accidently pressed Ctrl-F5 which is the Move/Resize command. Move the window to the appropriate location and press Enter to place the window there.

The Edit Window

When you first start the Turbo C++ development environment, you will usually see a gray like background. Pull down the 'File' menu and select 'New', this will give you an edit window. It is in the Edit window where programs are written. The Edit window in the IDE you are using works like most common text editors. If you type something, it will insert the characters at the current cursor location. The Borland IDE has an interesting feature known as syntax highlighting. Later in this lab when you load a C++ file, note the different colours in the edit window. The arrow and page up/down keys work as expected to move the cursor around. You should try typing a few sentences and then go back and try modifying some text using the Backspace and Delete keys to see the difference. I have noticed that these two keys usually seem mysterious to many students. A very useful keystroke in the IDE is the combination Ctrl-Y which erases the current line completely. Try creating a few lines and deleting one. Pressing the F5 button will make the current window as large as possible. Pressing the Alt-F3 button will cause the current window to close.

The Menus

  1. Press the F10 key to activate the menu bar. You will notice that the cursor is removed from the edit window and that one of the words on the help menu is highlighted.
  2. Press Enter to pull down the file menu. Moving the highlight bar to various menu entries will change the description on the status line.
  3. Press the left and right arrow keys to access the other menus to get a feel for how the IDE works. To access a particular menu, you can press the Alt key along with the highlighted letter. For instance, you can pull down the Compile menu by pressing Alt-C.
  4. Press the Esc key to leave the menu system and go back to the Edit Window.
  5. The convention used in these labs for menu commands is the form `File|Open' which means open the File menu and select the open command.

Opening a Lab File

  1. Select the menu File|Open. This will cause the Open File dialog box to appear.
  2. If you know the exact directory and filename of the file you are trying to retreive, you can type the full path and the file will be loaded. Normally, you will probably want to do the following. To open a file for the lab, you will type T: and press Enter . You will now see a list of files available on the T drive.
  3. Besides C++ files, the list will also contain a list of directories marked with a '\'. If the file you are looking for is not in the current directory, you can select another directory by highlighting the name of the directory and pressing Enter.
  4. Select the directories named COMP_SCI , FORD , then LABS . Now select the file HELLO.CPP .
  5. Scan through the file to see the different syntax highlighting colours and to get a feel for using the cursor keys.
  6. Before you can compile and/or run a program, it must belong to you. When you load any lab file from drive T, you must select 'File|Save as' and save the file to your M drive. In this case, after selecting the the menu items to save the file, type M:HELLO.CPP .

Compiling a Program

  1. Choose Compile|Make. This will cause the IDE to translate the C++ program into machine language (i.e. compile) and link the program. Did the program compile? Look at the number of `Errors' on the information box.
  2. Press Enter to close this information box and the `Message Window' will be opened listing all errors and warnings the compiler encountered. If the number of errors at times looks unnerving, don't worry. In C++ one small error near the top of the program will often result in several later on. Fix the errors one at a time starting with the first error. Don't try to fix the warnings until all the errors are looked after.
  3. Select the first error in the Message Window and press Enter. This will open the Edit window and place the cursor at the location the compiler has discovered the error. Note that the compiler is just guessing where the error has occurred and sometimes a bit of hunting will be necessary to track down the actual error.
  4. Make the program again by pressing F9. This time there should be no errors and no warning. Press a key to close this information box.

Running a Program

  1. Choose Run|Run (or press Ctrl-F9). You should see a prompt from the program asking you to enter an integer.
  2. Enter a 2 then another 2. Did you see the answer? Probably not, because when the program wrote out the answer really fast then the program stopped and returned control of the computer to the compiler (remember the last statement of the program?) To see the output of the program, press Alt-F5. To return to the edit window press any key.
  3. Try running the program a few more times. If you feel brave, you can try removing something from the program or adding some more stuff to see different error messages.

The HELP System

The IDE contains a set of Help screens which can sometimes be useful. Pressing Shift-F1 will give a list of commands for which help is available, move the cursor to highlight the word you are interested in. Press Esc to close the help window. A more interesting feature is the context-sensitive help. In the edit window move the cursor to the word return and press Ctrl-F1. This will cause the help window to appear with information about the return function. Please note that the help files are not meant to be used by novice programmers. The help files are written to assist experienced programmers by reducing the number of times they have to look information up in a paper manual. If you read a help file on a topic and are still confused, don't worry about. That is what the textbook and the instructor are for.

Exiting the system

To leave the IDE, select the menu `File|Exit' or type Alt-X. If you have worked on a file since the last time it was saved, you will be asked if you want to save.

Lab Exercises

In this particular lab, you do not need to submit anything. When you run accross questions in future labs, write the answer on a peice of paper and show it to the lab instructor before leaving.
  1. Load the file READ1.CPP . (Remember to save it on your disk!)
  2. Browse through the program and predict what the program will do.
  3. Make and run the program.
  4. Close the program by pressing Alt-F3 to get rid of all the existing windows.
  5. Open the file READ2.CPP .
  6. Once again, browse through the program to see if you can predict what the program does.
  7. Make and run the program.

End of Lab

Normally you will have a program that will have to be shown to the lab instructor. In the future, if you modify a program for the lab, make sure you save it to your account. Make sure you have signed the log book (it is probably just a sheet of paper) so that you receive credit for the lab.