tenWare Software

Visual Studio Code Snippets

Visual Studio provides the capability to build libraries of frequently used programming code called Code Snippets, that can be easily inserted into your code.

tenScripting provides a set of Code Snippets for writing HomeSeer scripts.  There are separate libraries for Visual Basic and C#. 

An example is the snippet that generates all of the code for the definition of a new HS script, including:  the definition of a new Class; the definition of the SUB Main; and the generation of code to split out multiple items from the single String parameter.  One of the most frequent issues tenScripting users have, is when they fail to properly define the SUB Main statement so that tenScripting and HS can properly identify it.  By using the Code Snippet, all of this is done with just a few key-strokes.  For a C# script, it also generates the statement that instantiates the hs and hs4 objects.

In the code editor, place the cursor at the end of a script file, and right-click on a new line, left-click Snippet, and then Insert Snippet. The following menu will appear:

Event without a Parm

Double-click HS3Snippets then double-click HS3 New Script.  The following will be inserted:

Event without a Parm

The cursor will be placed at the new Class Name for you to enter the name of your new script.

The process is similar if you are creating a script in the CSscripts project.  Select the HS4 New C# Script snippet from the HS4CsSnippets library to insert the following:

Event without a Parm