Code Snippets and Templates

Creating Custom Code Snippets

A code snippet must be composed using the xml schema and format illustrated below (for additional examples please refer to the snippet files located in the Snippets folder, under the application installation folder). In order to create a new custom code snippet, the following steps must be followed: First, create a new file with the extension .snippet, enter the xml content with all custom entries, and save it. The name of the file will be displayed in the Combine user interface. Then, in order to make use of the snippet in Combine, you must load it into Combine.

To create a custom code snippet, the following xml entries should be considered:
1. Title - not used in Combine 1.0, but will be used in future versions. It is recommended that the Title field will be identical to the snippet file name.
2. Shortcut, Description, Author - not used in Combine 1.0, but will be used in future versions.
3. Snippet Type - must be Expansion, as in the example below.
4. Literal - each Literal represents a snippet variable. Once the code snippet is opened in Combine, users can automatically replace the value of the variable throughout the snippet script using built-in Combine features.
5. ID (under Literal) - the name of the snippet variable as it appears in the script. When composing the snippet script, the variables must appear in the format $VariableName$. In the example below, one variable name is Database_Name, and the string $Database_Name$ is used to instantiate it in the script.
6. ToolTip - not used in Combine 1.0. This feature will be used in future versions, and the content of the ToolTip will be displayed whenever the user hovers over the snippet variable with the mouse.
7. Code - the SQL and T-SQL content of the code snippet should be placed under the Code xml element, after the CDATA (the CDATA clause is used to include text that will not be parsed as xml and will appear in Combine as entered).

Note: If the xml schema or content you entered is incorrect, either Combine will not load the snippet to the user interface properly, or the snippet will be loaded but will not behave as expected. To test your xml format, simply load the snippet into Combine and verify that it is added and can be used correctly.

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="">
       <CodeSnippet Format="1.0.0">
                   <Title>Create Database (Basic)</Title>
                               <ToolTip>Name of the new database</ToolTip>
                               <ToolTip>Database to use in the USE clause</ToolTip>
                   <Code Language="sql"><![CDATA[
/* =====================================================
Create Database (Basic) Template
======================================================= */

USE $Database_To_Use$

-- Drop the database if it already exists IF EXISTS (
FROM sys.databases
WHERE [name] = N'$Database_Name$')

DROP DATABASE [$Database_Name$]

CREATE DATABASE [$Database_Name$]

© 2001-2018 JNetDirect, Inc. All Rights Reserved.