The Snippet Manager
If you regularly use expressions or markup that have a common code structure, you could save yourself the trouble of repeatedly typing them out by instead using standard code templates known as Snippets. These snippets can be inserted into an expression, then altered to suit a specific purpose by replacing a small amount of standard text.
For example, you may regularly use a particular expression within your model, and many of its arguments are the same every time. The syntax of this expression might be as follows:
VARIABLENAME:= DateDiff( GetDate(), SECONDDATE, 1 );
This expression measures the number of days between today's date and a second, date, then stores that difference in a variable. By replacing the words VARIABLENAME and SECONDDATE each time the snippet is used, you can change the way the expression works.
Snippets are stored inside special XML files that have the .snippet file extension. Each snippet file can contain multiple individual snippets, which means you can share your custom snippet files with other users to ensure everyone has access to the snippets they need.
Although inserting existing snippets is designed to be easy for users of all levels, creating and editing them requires you to have a basic understanding of XML. You do not need to know how to do this if someone else in your organisation is in charge of doing it for you.
The interface for managing expression snippets can be accessed by opening the Expression Editor and selecting Tools > IntelliSense > Expression Snippets Manager.
The list on the left-hand side of the window displays all the snippet files currently available to you. These files are grouped under headings that denote their respective category folders. Selecting any file will cause the Information section on the right-hand side of the window to update, showing details particular to the selected file.
Selecting a snippet file displays additional information about that file.
At the top of the information panel is a drop-down menu labelled XML Snippets, which allows you to select which snippet in the chosen file you want to examine in more detail.
Viewing the snippets in a selected snippet file.
Snippet files are created and managed using an XML editor window.
Each snippet file can contain multiple snippets by adding more tags to the file's markup.
To learn how to manage snippets, refer to the following topics:
Description | Further Reading |
---|---|
Create a new code snippet file. | Creating a Snippet File |
Edit an existing code snippet file. | Editing a Snippet File |