Working with Libraries

A script library belongs to the model in which it was created, and is a container for actions and function sets. When you create a script, you do so within a library and therefore within a model. Quantrix script libraries let you share functions with other models, and share useful scripts with other users.

There are two methods of importing and exporting scripts: one uses a local repository specific to your installation of Quantrix, and the other is a file-based approach that permits sharing between different installations.

Sharing Scripts Between Models: the Repository

To facilitate easy exchange of scripts between your models, Quantrix provides a central application repository. This repository is a local database associated with your installation of Quantrix, into which you can export script libraries that you want to make available to any model. Libraries in the repository are not automatically included in new models. When you want to add a library from the repository to a particular model, you do so via a simple import procedure from a library in the script manager. You can import and export only libraries; actions and function sets cannot be exported individually.

You access the repository from the Script Manager. To illustrate the process, let’s use the repository to share a simple function set between two models. If you would like to follow along with this procedure, you can use the function set provided in the RepositoryExample.model file included with the sample models (Samples >Scripting > Getting Started Guide folder).

The Example function set includes a single function that always returns zero. We will export this function set to the repository and then import it into another model.

Exporting to and Importing from the Quantrix Repository

To export the function set, follow these steps:

1. If necessary, open the Script Manager by clicking Scripting -> Script Manager.

2. RepositoryExample.model contains a single library, Functions for Sharing, which contains the Example function set. You can browse the contents of the library in the Script Manager.

3. Right-click on the Functions for Sharing library and click Export to export it to the repository.  

Tip: You can also perform the export by highlighting the library and clicking the export button in the Script Manager toolbar.

4. The status bar displays a message indicating that the file has been successfully exported.

Note: If the function set has already been exported to the local repository, a Library Already Exists message dialog displays:

Choose Overwrite the existing library, or Export with a different name and enter the name to use.

To import the set from the repository into another model, follow these steps:

1. Create a new model into which you will import the set.

2. Open the Script Manager.

3. Right-click in a blank area of the script manager and click Import:



The import dialog appears.

Tip: You can also perform an import by using the import button in the Script Manager toolbar, or by choosing Import from the Scripting menu.

4. Select the Functions for Sharing library and click OK.

5. The library appears in the Script Manager within the new model. You can now use the Example zero function in this model.

Exporting to and Importing from the File System

For an even greater degree of flexibility in sharing scripts, you can export a library to the file system. Any Quantrix user can then import that library and use the scripts.

To export a library to the file system, follow these steps:

1. Open the Script Manager and locate the library you want to export.

2. Right-click on the target library, then click Export to File.

3. Choose a location and name for the exported file.

4. Click Save. The exported file will be given an extension of ".qsl".

To import a library from the file system, follow these steps:

1. Open the model into which you want to import the library.

2. Right-click the background of the script manager and click Import From File.

Tip: You can also import from the file system by choosing Import From File from the Scripting menu.

3. Browse to the ".qsl" file you want to import, then double-click it (or select it and click Open).

The new library should now be available in the current model.

Link Library to URL

You can right-click on a script library within a model and Link the library to a URL so that you can share scripts and related JARS using the linked location. You can update scripts with other users of a model using an Export option. The URL format to use in Windows is shown in the dialog. OSX users must use 2 forward slashes rather than 3 forward slashes (file://Macintosh HD/users/ for OSX, vs file:///c:/users/ for Windows).

Note that if you export a script to a valid folder without giving it a name, it will be given a name such as 85af2cc5-6378-446f-8313-3c0fb82e0017.qsl.

Other users of a model in which you link a script to a URL receive a security warning notice about the linked script, and are asked if they want to allow it.  If they click No, no scripts in that URL will work; if they click Yes, any scripts in that URL will work.

If you update a script that you have linked to a URL, you can Export to URL to update the script at the linked location. You'll be prompted whether to overwrite the existing script, or to give it a new name rather than overwrite.

Any other users of the model containing the script who open the model after you've updated the script get the updated script automatically with a message that it has been updated.

You can right-click on a script library and Import or Export scripts. You can import from a local script repository in Modeler or from a file location, and you can export to a file location, a local script repository in Modeler, or a Linked URL.

To support the sharing and updating of scripts, scripts and libraries are timestamped. The timestamps are used in import and export, and to update scripts that are shared.


Tools for Developing Scripts