About this task
Template support is available for both ILE RPG, ILE COBOL,
and C++ programs. You can use templates to predefine a structured
description of coding patterns that reoccur in your source code. The
LPEX editor supports the use of templates to fill in commonly used
source patterns. For example, if you often use a particular coding
pattern, you could avoid typing it each time that you want to use
it by starting with a template. Invoking content assist at the point
of this pattern in your code gives you a list of possible templates.
Selecting a template will insert the code into the LPEX editor.
Restriction: For RPG source, you can only use templates for
free-form RPG.
To create a template:
- Select Window and click Preferences.
- Click .
- Select from the listed languages.
- Select Templates.
- Click New.
- In the new template dialog box, type the name of the template,
and select a language from the Context drop-down
list.
- In the Content field, type the code that
you want content assist to insert.
Template variables may be used
in the template content. Variables are resolved to their concrete
values when the template is evaluated in its context. The following
variables are available:
- ${cursor}
- Specifies the cursor position when you leave the template edit
mode.
- ${date}
- Evaluates to the current date.
- ${file}
- Evaluates to the base name of the file.
- ${time}
- Evaluates to the current time.
- ${user}
- Evaluates to the user name.
- ${year}
- Evaluates to the current year.
- Click OK twice.
To insert this new template, type the template name in your
code, and press Ctrl+Space.
The
new template name that you created appears in a popup window. Double-click
on this completion to insert the contents of the template into your
code.