Coding Faster with Templates
Posted: Mon Sep 27, 2004 2:15 am
Zeus has a template feature designed specifically to make the task of programming faster and easier.
To better understand how templates work, run the following test:
While the file was named c:\temp\test.c the foi, while and ife where expanded to read as follows:
but when the file was renamed to be c:\temp\test.txt the entered text remained unchanged:
This happens because the foi, while and ife are templates defined in the C/C++ Document Type, where as there are no such templates defined in the Text Document Type.
The Zeus configuration model makes it possible to define templates that work within the scope of a given file or alternatively, it is also possible to define the same template to produce a totally different results depending on the file being edited.
It is also possible to define a template to have global scope meaning it will work for all file types. This is done by defining the template in the Default Document Type.
As an example of such a template, repeat the test above but this time use the dte date time template.
To better understand how templates work, run the following test:
- File New menu to create a new file
- File Save As menu and save the file to c:\temp\test.c
- Type in foi<space or enter> and move the cursor to the end of the file
- Type in while<space or enter> and move the cursor to the end of the file
- Type in ife<space or enter> and move the cursor to the end of the file
- Type in File Save As menu and save the file to c:\temp\test.txt
- Type in foi<enter> and move the cursor to the end of the file
- Type in while<enter> and move the cursor to the end of the file
- Type in ife<enter> and move the cursor to the end of the file
While the file was named c:\temp\test.c the foi, while and ife where expanded to read as follows:
Code: Select all
for (int i = 0; i < ; ++i)
{
}
while ()
{
}
if ( == )
{
}
Code: Select all
foi
while
ife
The Zeus configuration model makes it possible to define templates that work within the scope of a given file or alternatively, it is also possible to define the same template to produce a totally different results depending on the file being edited.
It is also possible to define a template to have global scope meaning it will work for all file types. This is done by defining the template in the Default Document Type.
As an example of such a template, repeat the test above but this time use the dte date time template.