What is a template?
Templates are a means that allow you to make the most out of the keyboard
while editing a language. A template (in Prism Editor Terms) is
a structured piece of code that can be called up using a combination of
a HotCode with a hotkey. The text defined in the template will replace
the hotcode. To use the hotcode in text you must follow it with '..' (See
the interactive example in What's New).
As you type, all hotcodes are highlighted by a '
'
in the status bar. The following templates is defined for the VHDL
'if' hotcode.
If ( $$ ) then
$$;
Elsif ( $$ )
then
$$;
Else
$$;
End if; |
Notice the $$.
This is what's called the Navigation field. after a template expansion,
the first $$ will be selected. This can be useful to place the cursor in
the most intuitive place. Also subsequent $$ fields can be reached using
'
'. The following
key sequence will produce the result below.
if.. x < 3
y:=y + 1
x <
6
y:=y + 2
y:=0
If ( x <
3
) then
y:=y
+
1;
Elsif ( x <6
) then
y:=y
+
2;
Else
y:=0;
End if; |
Defining your own Language Specific Templates.
New templates can be defined very easily. Just go into the [View->Languages]
definitions form and select the language (If you are currently using a
language, it automatically defaults to this).
Select the [Templates] Tab. In this tab, you can add/delete
templates or change the templates code.
The quickest way to learn new templates is to look at some
sample templates included.
Using Prism Variables
The most commonly used variables for templates are the $Input and $Output
fields. The $Input variable will request information from the user
and this can be used again with the $Output field. The $Input field
will be stored in an array whose zero-based index will be the number of
the $Input field. e.g.
$Input(Name)
$Input(Address)
$Input(Phone)
The input from $Input(Name)
will be stored in $Output0
The input from $Input(Address)
will be stored in $Output1
The input from $Input(Phone)
will be stored in $Output2
The following VHDL example shows how useful this is. This example is
used for generating a clock process based on a RESET Signal and CLOCK signal.
$Input(Enter RESET Name)
$Input(Enter CLOCK Name for $Output0)
-- This is the
Clock Process
prClock:
--
process($Output0,$Output1)
Begin
if $Output0 = '0' then
-- Reset Clock Signals
elsif $Output1'event and $Output1 = '0' then
--Clock Signals
end if;
End process; |
A list of other variables can be found in Prism
Variable Reference.