September, 1994 - Vol. 1 No. 9
In a perfect world, every program would contain enough appropriate comments for the average programmer to maintain the code. However, some programs implement procedures or techniques that require pages of text to explain. Obviously, few of us are willing to embed multipage comments in our source code files.
In the Borland C++ 4.0 Integrated Development Environment (IDE), you can make a text file or word processor document a noncode element of a project. By placing long procedure descriptions in a separate file, you can limit the scope of embedded comments to the content of the source files.
In this article, we'll show how you can easily add new
or existing text files as part of your projects. In addition,
we'll show how you can associate text files with specific
code components of the project.
To add a text file to a project, you'll simply add a new project node from the project window and specify a noncode filename for the node. If you enter a filename with a TXT extension, you'll be able to edit this file with the IDE's built-in editor. If you enter a filename with an extension that's used by a specific word processor (for example, Word for Windows uses DOC files), you'll need to make sure you've created an IDE tool for launching that program.
By default, the IDE won't try to build noncode files that you add to a project. Instead, the IDE automatically sets the Exclude From Parent Build attribute for noncode file project nodes and displays a gray box next to those files in the project window, as shown in Figure A.
Figure A - The IDE won't try to build text files that are part of a project.
To add a text file node as a child of an existing node, you'll
choose the existing node first and then add the new text file
node. To add a text file node that isn't a child node,
you'll simply add it as a child node and then promote that
node to the top level of the hierarchy. To see this in action,
let's add some text files to an existing project.
To begin, launch the Borland C++ 4.0 IDE. When the IDE's
main window appears, choose Open Project... from the
Project menu. When the Open Project File dialog box appears, enter
\bc4\examples\windows\whello\whello.ide
in the File Name entry field and click OK.
When the Project window for the WHELLO.IDE project appears, right-click on the name whello [.cpp] and choose Add Node from the pop-up menu, as shown in Figure B.
Figure B - You add a text file node just as you would any source node.
When the Add To Project List dialog box appears, enter WHELLO.TXT in the File Name entry field, as shown in Figure C. Click OK to create this node in the Project window.
Figure C - You use the Add To Project List dialog box to specify the new node's filename.
When the Project window reappears, you'll see the whello [.txt] node as a child of the whello [.cpp] node, as shown in Figure D. (If you've already built this project, nodes for each of the header files that whello [.cpp] uses will appear below the new text file node.)
Figure D - If you add a new text file node to an existing node, the new node will be a child of the original node.
If you want to move the whello [.txt] text file node from its current location to the top of the project hierarchy, click on the text file node to select it and then press [Alt][up arrow] twice. Each time you press [Alt][up arrow], the IDE will move the text file node up one position in the Project window.
To open the text file by using the IDE's built-in editor, double-click on the name whello [.txt] in the Project window. When the data-file editor window appears, enter a description of this program's purpose.
To close the editing window, double-click on its System menu icon.
To exit the IDE, chose Exit from the File Menu.
Few projects contain complete process descriptions or design summaries
as comments in the source code. By adding them directly to your
projects, you can maintain a logical association between text
files and the parts of a program they describe.
Copyright (c) 1996 The Cobb Group, a division of Ziff-Davis Publishing Company. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of Ziff-Davis Publishing Company is prohibited. The Cobb Group and The Cobb Group logo are trademarks of Ziff-Davis Publishing Company.