Syntax Errors

By far, the most common problem that will be encountered with the use of scripts is a script-compilation problem related to a syntax error. While STK will attempt to report errors that it finds, errors in the scripts themselves are much more difficult to diagnose since they arise not in STK per se, but in the language's processing of the script. Often, the language detects an error but will not identify the cause of the problem back to STK.

We strongly recommend that users check for syntax and compilation errors in the scripts before using them with an STK plugin script.

Checking MATLAB Scripts

To check a MATLAB .m file, you will need to run the script within MATLAB in two modes: register and compute. You will need to create the correct input struct for each case.

Checking VBScript Scripts

To check a VBScript script, simply double-click on it in the Explorer browser: any compilation errors will be reported in a pop-up window. If no errors are detected, then no indication is given, and you can assume that no compilation problems were encountered.

There still may be a run-time problem—the Microsoft script debugger can be used to diagnose these problems.

Checking Perl Scripts

To check a Perl script, open a Command Prompt and run the Perl script as you would normally do. Compilation errors will be printed in the window.

Checking for Proper Registration of Inputs and Outputs

Both VBScript and Perl provide a mechanism to print out (or pop up a panel containing) a list of inputs and outputs, along with their representation. This can be used during script development. Once the script has been shown to work correctly, simply comment out the lines that print this information.

Checking for Valid Values

To check for valid values, simply print them out every so often during the compute call, either by saving them to a file or popping up a panel containing the values. We strongly recommend that you do not pop up panels for every call to compute, as there may be thousands of calls made to compute and you will need to dismiss the panel for each call.

In MATLAB, on a PC, you can access variables in another way. You can declare certain variables global in the .m file and declare them global in the workspace (i.e. at the input prompt). Then, after running, you can print these variables to check whether they are correct or not.

For VBScript, it may be easier to output informational data directly to Microsoft Excel than to save the data to a file.

Using STK Connect

Users cannot issue STK/Connect commands to STK from inside a plugin script. This causes an infinite loop in the software.

Further MATLAB Issues

File Location

The MATLAB application locates files to execute by searching the hierarchy of paths. The search path is updated automatically every time a scenario is loaded or created. However, paths are only added to the MATLAB search hierarchy if they exist in the file system. For example, if a new scenario is created that needs to use MATLAB Plugins, the following steps must be taken:

Alternatively, the Plugins can be placed in the user configuration area before STK is started, in which case these Plugins will be immediately available for every scenario.

Editing MATLAB Files in Use by STK

Care must be taken when editing MATLAB files while they are being used by STK. For example, Vector Geometry Tool custom axes and vectors must be reloaded in order for the changes to take effect. In general, only STK related information will be cleared from the MATLAB workspace. This means that if a MATLAB Plugin file uses other MATLAB files, changes to those files will not take effect until the user manually clears them from the MATLAB workspace. This can be done by executing clear functionName in the MATLAB command window opened by STK.

MATLAB Plugin Scripts on UNIX

On UNIX systems, MATLAB will be started in the background—no GUI or command prompt is available. To debug MATLAB plugin scripts on UNIX, use a file to store informational data.

STK 11.2.1 Programming Interface