Using Quincy 2000

It is usually more convenient to use an integrated development environment than to issue commands yourself. For this book I have modified Al Stevens' excellent Quincy environment to work with UnderC. Quincy also works with free compilers like GCC and BCC55. It saves you from having to remember (and type) the commands yourself, and it keeps track of breakpoints. UCW runs as a separate program, and Quincy sends it # commands. If, for some reason, UCW gets confused (which happens occasionally), you can shut it down and restart it separately from Quincy, and Quincy will pick up where you left it.

Figure A.1 shows Quincy 2000 in action, indicating the meaning of the most important icons on its application toolbar.

Figure A.1. Most important operations using Quincy 2000.


Entering a Program into Quincy

Here is how you create a simple C++ program with Quincy:

1.
Create a new document in Quincy by selecting File, New, by pressing Ctrl+N, or by clicking the first icon on the Toolbar.

2.
Specify “C++ Source File” in the list of choices.

3.
Quincy creates a new file called noname1.cpp. In this window, type the usual “hello world!” program, as shown:

#include <iostream>
using namespace std;

int main()
{
  cout << "Hello, World!" << endl;
}

4.
You can now save this with File, Save, by pressing Ctrl+S, or by clicking the second icon.

NOTE

Syntax highlighting shows the C++ keywords, the variables, comments, and string literals in different colors. This can be very useful for visually detecting problems (for example, forgetting to finish a comment or a string).


Running a Program with Quincy

To run the program, follow these steps:

1.
Select Debug, Run, press F9, or click the “running man” icon.

2.
Quincy automatically does three things: It saves the file (if the file was changed), it compiles the file by using #l, and it runs the program by using #r and any command-line arguments.

3.
A separate program window that contains your program output appears within milliseconds. If there was a compile error or a runtime error, you are told about it and are immediately placed at the appropriate line, which saves you a lot of labor. If a program gets out of control, clicking the stop icon causes the #s command to be sent to UCW.

Specifying Command-line Arguments

To specify the command-line arguments for program execution, follow these steps:

1.
Select Tools, Options, and you will get the Options dialog box.

2.
Select the Run tab and then type in any command-line arguments, or you can choose to let Quincy prompt you for these arguments each time the program is run.

Switching between UnderC and GCC

In the Options dialog box, note the “Run UCW” option; if you switch it off (it is on by default) and run the program as you did before, the program is compiled and linked with GCC. The progress is indicated in the status bar at the bottom right of the main window; if there are any errors, a list of errors appears, and you can click the list to inspect.

A shortcut for switching between UCW and GCC is Options, Use UCW. This menu item will be checked if you are currently using UCW. (You can also toggle this setting with Ctrl-U.)

Setting Breakpoints with Quincy

You set breakpoints by using the “hand” icon on the Toolbar (a shortcut is function key F2), and these appear as a small hand icon in the left-hand margin of the editor window. When the program stops, this icon changes to show that execution has halted at that point.

The two stepping operations (controlled by the “boot” icons) are not available for UCW, but are for GCC. Single-stepping means going through the program one line at a time; the difference between the two operations is that the first will go into a function definition, and the second will “step over” (hence the “raised boot” icon) the function.

The Watch Window

The watch window (which you open by selecting Debug, Watch or by pressing Ctrl+W) lets you set a number of variables (or expressions) that you can inspect. This works slightly differently in UCW mode than when working with GCC, because in UCW mode it is possible to inspect variables when the program is running, but not halted. You can also inspect more complicated expressions in UCW mode because the full power of the UCW expression compiler is available.

You can always switch to the UCW window and work from there; this gives you the flexibility to call specific functions, and so on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.133.49