[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppBuilderCodeTemplate

Code template

A feature in C++ Builder to generate templated code.

When you use the key shortcut CTRL-J, a menu pops up with your code templates.

Make your own code template

C++ Builder 6

You generate the templates in 'Tools | Editor Options | (tab) Code Insight | Add template'. One of my templates is:
for (int i=0; i!=|; ++i)
{
}
The bar '|', denotes where your cursor will be when you called this code template. I called this template 'i'.

C++ Builder 2006 and Turbo C++ 2006

Go to 'View | Templates' to view the templates. Choose 'Edit' to edit one. The templates must be written in XML.

I (Bilderbikkel) don't know how to do it yet .

Note: if you enter an unparsable XML statement, you'll get the error 'Access Violation at address 5539BA08 in module 'codetemplates100.bpl'. Read of address 00000000'. This error will remain until restarting; fixing the XML code will not remove this error.

Examples

Below is the for-loop code template, supplied with Turbo C++ 2006.

<?xml version="1.0" encoding="utf-8" ?>
<codetemplate	xmlns="http://schemas.borland.com/Delphi/2005/codetemplates"
				version="1.0.0">
	<template name="for" surround="true" invoke="auto">
		<point name="expr1">
			<hint>
				initial expression
			</hint>
			<text>
				i = 0
			</text>
		</point>
		<point name="expr2">
			<hint>
				loop condition
			</hint>
			<text>
				i &lt;= 10
			</text>
		</point>
		<point name="expr3">
			<hint>
				loop expression
			</hint>
			<text>
				i++
			</text>
		</point>
		<description>
			for statement
		</description>
		<author>
			Borland Software Corporation
		</author>
		<code language="C" context="methodbody"><![CDATA[for ($expr1$; $expr2$; $expr3$) {
$selected$$*$$end$
}
]]>
		</code>
	</template>
</codetemplate>


last edited (June 10, 2007) by bilderbikkel, Number of views: 2519, Current Rev: 7 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.