Scripting Environments

By convention, the extension of the filename determines the language to be used:

Languages and Extensions

Extension Language
.m MATLAB
.vbs VB Script
.pl Perl

The name of the function that is called by a plugin script is based on the filename. For example, the name of the function called when using the filename
C:\stk\user1\VB_ForceModel_Eval.vbs is VB_ForceModel_Eval.

This convention is the same as the MATLAB convention for dealing with user defined functions (i.e., .m files). This convention was chosen to avoid name collisions since MATLAB and VBScript do not understand the concept of namespaces.

MATLAB Environment

Only one copy of MATLAB is opened by STK for use with plugin scripts. All MATLAB plugin scripts share the same workspace environment. STK does not connect to MATLAB until some MATLAB plugin script attempts to execute a script. This may occur during application start-up or when loading scenario files, depending on the plugin point being used.

MATLAB Plugin Script Locations

When the MATLAB Engine is opened, STK plugin script folders are added to the MATLAB path. However, if you add a new folder after the MATLAB engine has initialized, that folder will not be added to the MATLAB path. You can add the newly created folder to the MATLAB path in one of two ways:

Sharing Global Variables

In MATLAB plugin scripts, you can share global variables, as shown in the following example:

global frequency;

Declaring a variable using the global keyword allows it to be used in other scripts.

VBScript Environment

Only one copy of a VBScript engine is opened by STK for use with VBScript plugin scripts. All VBScript plugin scripts share the same workspace environment. STK does not create a VBScript environment until some VBScript plugin script attempts to execute a script. This may occur during application start-up or when loading scenario files, depending on the plugin point being used.

As part of the creation process, all VBScript files (i.e., files with extension .vbs) within certain directories are automatically loaded into the workspace. You may add your own VBScript files to these directories and they will be automatically loaded as well. The directories are:

where <STK install folder> refers to the STK installation directory, <STK user area> refers to the STK User's directory, and <STK all users area> refers to the directory that contains STK application data for all users. A success or failure message will be written for each of the files found and loaded.

This mechanism allows you to create certain VBScript utilities that other VBScript scripts may utilize, since there is no internal mechanism in VBScript to load and execute another script.

Perl Environment

Only one copy of the Perl interpreter is opened by STK for use with Perl plugin scripts. All Perl plugin scripts share the same workspace environment. STK does not create a Perl environment until some Perl plugin script attempts to execute a script. This may occur during application start-up or when loading scenario files, depending on the plugin point being used.

As part of the creation process, all Perl files (i.e., files with extension .pl) within certain directories are automatically loaded into the workspace. You may add your own Perl files to these directories, and they will be automatically loaded as well. The directories are:

where <STK install folder> refers to the directory path that is the parent of STKData, and <STK user area> and <STK all users area> refer to the user's configuration directories. A success or failure message will be written for each of the files found and loaded.

STK 11.2.1 Programming Interface