Coding Faster with Templates

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2445
Joined: Fri Aug 13, 2004 5:10 pm

Coding Faster with Templates

Post by jussij » 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:
  1. File New menu to create a new file
  2. File Save As menu and save the file to c:\temp\test.c
  3. Type in foi<space or enter> and move the cursor to the end of the file
  4. Type in while<space or enter> and move the cursor to the end of the file
  5. Type in ife<space or enter> and move the cursor to the end of the file
  6. Type in File Save As menu and save the file to c:\temp\test.txt
  7. Type in foi<enter> and move the cursor to the end of the file
  8. Type in while<enter> and move the cursor to the end of the file
  9. Type in ife<enter> and move the cursor to the end of the file
NOTE: In the instructions above the <space> represents the space bar and <enter> represents the enter key.

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 ( == )
{
}
but when the file was renamed to be c:\temp\test.txt the entered text remained unchanged:

Code: Select all

foi
while
ife
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.
Last edited by jussij on Mon Jan 30, 2012 2:51 am, edited 2 times in total.

djsykora

Templates for VHDL

Post by djsykora » Wed Apr 06, 2005 3:27 pm

Jussij,
Are you aware of any templates for VHDL? Before I roll my own, I would like to know if someone else has already done it. Also, is there a file where the templates are stored? It may be easier to edit that instead of using the edit box provided in the templates window.
Thanks,
Doug

Guest

Post by Guest » Wed Apr 06, 2005 11:29 pm

Hi Doug,
Are you aware of any templates for VHDL?

Unfortunately not :(
Also, is there a file where the templates are stored?

They are held in the ZeusXXX-template.ext found in the zConfig directory.
It may be easier to edit that instead of using the edit box provided in the templates window.

Unfortunately, this (like the other Zeus configuration files) is a binary file, so it can not be easily edited :(

Looking back, the use of a binary format for the configuration was the error in design. The binary file has the great advantage in that it requires no validation (ie it is machine generated) but is also totally user unfriendly :(

The very long term plan is to move this configuration data into some form of text file format, probably XML, but that is some time off.

The only solution I can offer to to first write the templates to a simple text file for example:

Code: Select all

For i Loop
foi
for (int i = 0; i < \c; ++i)
\t{
\t}

For j Loop
foj
for (jnt j = 0; j < \c; ++j)
\t{
\t}
Next start up a second copy of Zeus using the zeus.exe -s command line, open the template configuration dialog in this second copy and cut/paste the details from the first copy into the template edit field.

This is far from ideal solution, but I find it better than trying to write the templates using the postage stamp sized edit field found in the configuration dialog.

Jussi

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 34 guests