Snippets: Difference between revisions

From SMath Wiki
Jump to navigation Jump to search
(Created page with "SMath Studio has a built-in mechanism for extending functionality by creating user snippets. Such snippets are created based on the usual calculations and, if necessary, are embedded in the other calculations, giving users the opportunity to reuse previously prepared logic many times. == Snippet Creation == Snippet is based on a standard calculation prepared in SMath Studio. To create such a snippet you need to...")
 
No edit summary
Line 17: Line 17:
# Using the list of available dynamic input assist elements:
# Using the list of available dynamic input assist elements:
#: On the calculation page, start writing the [[Snippets|snippet]] shortcut and use the drop-down list to select the desired one (the final selection can be made either with the mouse or with the keyboard, using the tips):
#: On the calculation page, start writing the [[Snippets|snippet]] shortcut and use the drop-down list to select the desired one (the final selection can be made either with the mouse or with the keyboard, using the tips):
# Using built-in [[SMath Studio]] [[Extension Manager]].
# Using built-in [[SMath Studio]] [[Extensions Manager]].
#: In the dialog box that opens, in the list on the left, select [[Snippets]] to display all locally available [[Snippets|snippets]]. Then select the desired [[Snippets|snippet]] and click the ''Paste'' button.
#: In the dialog box that opens, in the list on the left, select [[Snippets]] to display all locally available [[Snippets|snippets]]. Then select the desired [[Snippets|snippet]] and click the ''Paste'' button.



Revision as of 16:56, 21 January 2025

SMath Studio has a built-in mechanism for extending functionality by creating user snippets. Such snippets are created based on the usual calculations and, if necessary, are embedded in the other calculations, giving users the opportunity to reuse previously prepared logic many times.

Snippet Creation

Snippet is based on a standard calculation prepared in SMath Studio. To create such a snippet you need to perform the following steps:

  1. Create a new calculation in SMath Studio.
  2. In the created calculation, add a custom function, procedure, define the necessary variables or units of measure that you want to provide access to.
  3. Upon completion of filling the calculation with logic, you need to define the meta information of the calculation, for which you need to go to the File > Properties... dialog.
  4. On the Summary tab of the File Properties dialog, set at least the Title, Author, and Description fields.
  5. On the File Settings tab of the File Properties dialog, set the Snippet Shortcut field, which will help you quickly insert the stub into future calculations. We recommend that you use unique and short text for the label without spaces or special characters. As an example, you can see the Snippets built into SMath Studio, such as grads and degrees.
  6. Save the resulting calculation locally and move it to the following folder on your PC:
    %APPDATA%\SMath\extensions\snippets

After these steps, snippet will be available for local use.

Using Snippet

There are two ways to insert the available snippets into the calculation:

  1. Using the list of available dynamic input assist elements:
    On the calculation page, start writing the snippet shortcut and use the drop-down list to select the desired one (the final selection can be made either with the mouse or with the keyboard, using the tips):
  2. Using built-in SMath Studio Extensions Manager.
    In the dialog box that opens, in the list on the left, select Snippets to display all locally available snippets. Then select the desired snippet and click the Paste button.

Publishing Snippet

Publishing your snippet to Root Licensing Server for free access by third parties is optional.

To make your snippet a part of the standard process for delivering it to the other users, you need to complete the following steps:

  1. Go to Root Licensing Server and make sure you are logged in with your account.
  2. Go to the Extensions registration page.
  3. On the registration form, select Extension type: Snippet and specify the path to the snippet file, then click the Register button.