Your XEmacs window should look something like this.

Now let us begin completing and debugging the program.
| Start by marking the first three lines of the program (i.e., the first
three lines in the XEmacs buffer) using the mouse, as follows:
|
Note that you can press Ctrl-c Ctrl-c to do the same thing. The three lines of text are now preceded by // to mark this as a comment. A comment is not included as part of the executable program. This can be very useful when you are trying to debug a program and want to comment out a portion of your code in attempt to locate the error. Later you can uncomment that portion of the code by selecting the commented code with your mouse, and then choosing the "Uncomment Region" command from the "Resolve/C++" menu.
Now go to the end of the program. After the comment that reads //
Close input and output streams, we need to add a statement that closes
the output stream. In Resolve/C++ programs if you open up a Character_IStream
or Character_OStream object you must remember to close it.
|
output.Close_External (); |
Note that the line is automatically indented when you press Enter, which is something you can do manually for any line by pressing the Tab key while anywhere on the line. In other words, Tab doesn't insert a tab character when you're using Resolve/C++ mode in XEmacs, but indents the line to where XEmacs thinks it should be. That it is indented too far is an indication that XEmacs thinks there is a syntax error somewhere above it. We will find and correct this error later. In the absence of such syntax errors, the current line would usually be aligned with the rest of the statements.
Occasionally you might have to manually change the indentation from what XEmacs wants to do. However, if you find yourself doing this a lot, then probably you're making it hard on yourself by trying to use different indentation conventions than XEmacs tries to support. We strongly recommend sticking with the indenting conventions used in code samples, which is what XEmacs automatic indenting tries to achieve, and usually (but not always) does.
Save the current version of Euclid.cpp by using the "Save Euclid.cpp" command from the "File" menu or by pressing Ctrl-x Ctrl-s.
| Previous | Table of Contents | Continue |