Making and using Templates


Dev-C++ can create and manage template files. Those templates contains information for creating automatically specific projects of your own. Dev-C++ contains 5 default projects, but it lets you design your own too with templates.


Making templates :


To create a new template, click on the File menu and then on “New template file”.

This will bring you the Template Builder, which creates and registers template files in Dev-C++.


Template Information : Enter the name, description and category of your template. You can also select an icon, which will be used by the executable generated after compiling a template project.


Editor information : Here you can set the cursor position that will be set when creating a template file. For example, if your templates contains the following default code:


int main()

{

}


you should put the following cursor position :

Column = 4 (like for a TAB)

Row = 3 (points to the third line, where the text is empty).

You need to set cursor position for C and C++ codes.

Project information : This is for setting the default options your template will generate for a project. They are the same as in Project Options.


Code : Type in the text fields the default C/C++ codes that will be used when creating a project from your template. Default code can be for example:


#include <stdio.h>

int main()

{

}



When you are ready to save and add your file to the Template list, click on the Save button, and type a filename in the dialog box that follows.



Using templates :


Creating a project from your template is the same as for creating usual projects. Click on the File menu in Dev-C++, then on “New Project…”. On the following dialog, click on the “Custom Templates” tab sheet, this will bring you the list of available templates to create a project from. Select a template and press the OK button (or double-click on the selected icon), and a new project will be created using the default options and code as you wrote in your template.


Deleting templates :


In the New Project dialog, select the template you are willing to delete and press the DEL (delete) button on your keyboard.