views:

396

answers:

2

I've had a major annoyance with the Borland/Codegear C++ Builder IDE for some time now. When I code I always use a standard layout for the code files. I have a standard header that I use, including, ie. the Licens of the file, filename, date, etc.

But I haven't been able to find anywhere to insert this, so that when I - for instance - create a new unit, get this header inserted automatically. Of course I can just paste it in, every time, but it gets a bit irritating to use time doing this.

So my question is - is it possible to create a file template for default C++ files or modify the existing ones so that they always start with my predefined layout. My fear is that just as with most other things in the C++ Builder IDE, this is hardcoded into it.

Currently creating a new unit creates a .cpp file with:

//---------------------------------------------------------------------------


#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

and a corresponding header file with:

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#endif

This is what I wish to alter to my own defined layout.

I'm using Codegear C++ Builder 2007.

Any help would be appreciated.

+3  A: 

See "Adding Items to the Object Repository" in the help file.

Basically, 1. Create the unit file(s) as you wish 2. Go to Project -> Add to Repository 3. Add information. 4. It will be available from the File -> New... area

There are also ways to share and edit repository items. The default distribution items are not quite as flexible, but creating your own should do just what you need.

Kris Kumler
I think I tried doing that but had problems adding units to the repository, seemed I could only add controls. Further more this will only work with units.I will have to make a version for a form, unit, datamodel, control, etc. In order of always having the default header information present. I will ofcourse give it a shot tomorrow, and see how it goes. But in my oppinion not having such an option is a mistake from Codegear. Thanks for the answer though, I will look into it shortly.
TommyA
It worked that way, don't know why I didn't think of that before - thank you. Still it can irritate me that there isn't a default way to add headers. But then again, that is whole different story.
TommyA
+1  A: 

For the defaults, see the answers to the question on reducing the "uses" clause boilerplate also located on stack overflow. This would require the same changes.

skamradt
The downside to that though, wouldn't it likely be overwritten when the product is upgraded?
Kris Kumler
Actually that is a pretty nice to know. But I would have wished they had moved the data to an external file. Preferably in the user directory. Thanks for sharing.
TommyA