Script Snippets

Script snippets are small sections of code that can be inserted into a larger script. They are typically used to perform specific tasks or functions within the overall script and allow you to reuse code and save time by not having to write everything from scratch.

Using Script Snippets

There are two types of script snippets, syntax snippets and functional script snippets.

  • Syntax snippets consist of code that is used to create common code syntaxes like loops or conditional statements.

  • Functional snippets consist of code that is used to perform a function or operation such as creating a new Jira issue.

There are two ways to use the snippets feature. The first way is when you want to create a new script from a snippet. The second method is to insert code into existing scripts.

New scripts from snippets

In order to use this there must not be any scripts open in the SIL Manager. With all scripts closed you will see a Quick start button in the editor panel of the SIL Manager.

 

image-20240130-155937.png

Clicking the Quick start button will launch a new menu to create a new script from a code snippet. To create the script you will need to provide the following information:

  • Script folder - this required field specifies which folder the script will be created in. All scripts can of course be created directly in the silprograms folder but we recommend using subfolders.

  • File name - this is the name you wish to give to the new file and is also required. We suggest using intuitive names and including the .sil extension in the file name but not mandatory.

  • Snippet - this is the bit of reusable code you wish to start writing the script with.

image-20240130-165748.png
Creating a new file from a snippet

Inserting snippet code

If a script is already open there will be two options in the menu bar for inserting snippets:

  1. Insert - this menu contains the snippets specifically for syntax code such as loops and conditional statements. See the Syntax Snippets section of the Script Snippets Code page for more information about these snippets.

  2. Snippets - this menu contains the functional code snippets such as creating a new Jira issue. See below in the Functional Snippets section of Script Snippets Code page for more information about these snippets.

Note: The exact same snippets exist between these two menus and the menu shown for creating a new file from a snippet.

Once a snippet has been selected the snippet code will be inserted into the existing file.

Multiple snippets can be inserted into a single file to be combined by the user into custom scripts.