Installation
This topic provides installation instructions for MATLAB, VBScript, Perl, and Python users.
Installation for MATLAB Users
To use MATLAB scripts, you must install an STK-supported version of MATLAB. (Check www.agi.com/matlab for a list of MATLAB versions supported by STK.)
The MATLAB debugger can be used to debug a MATLAB function when the function is called directly from MATLAB itself; however, it is not compatible with functions called from outside MATLAB; using the MATLAB debugger with STK MATLAB plugin scripts can cause both programs to hang or to crash.
If MATLAB was started by STK, then the proper manner to close MATLAB is also from STK. To close MATLAB, open the application Preferences from the Edit: Preferences menu item, go to the MATLAB page, and click the Close MATLAB button to close MATLAB. In fact, the quit command in MATLAB will not quit MATLAB if STK has opened it. The only way to quit MATLAB once started by STK is to quit STK, use the Close MATLAB button as described above or to use the command 'quit force' at the MATLAB prompt.
Installation for VBScript Users
VBScript is automatically installed with Microsoft Windows and is available free. There is no further installation step required.
The VBScript functionality in Windows is enabled through the file atl.dll. To use STK plugin scripts, you must have a copy of VBScript delivered with an STK-supported Windows operating system.
You need to register AgScript.dll as a COM server. Open a Command Prompt and change directories until you are in the directory containing the STK executables and dll's. The AgScript.dll is in this directory. Now run:
regsvr32 AgScript.dll
Stay alert to distinguish between VBScript (Visual Basic Scripting Edition), VB (Visual Basic), and VBA (Visual Basic for Applications). Some keywords and functionality available in VB/VBA are not available in VBScript. Moreover, several VBScript books document features that are not available in VBScript (but are available in VB/VBA). You may want to purchase a VBScript book that is careful about this distinction.
Regsvr32.exe requires administrator rights in order to register a plugin. Once registered, it's available to all users on that machine (provided that the actual file location on the disk does not change).
It is sometimes difficult to find a system administrator to register the plugin though. In this case, we have provided a VBScript utility - register_wsc_hkcu.vbs - in the STK installation directory under <STK install folder>\CodeSamples\Extend.
The utility will register a Windows Script Component to the HKEY_CURRENT_USER area of the Windows registry rather than HKEY_LOCAL_MACHINE. To run the utility, open a command prompt window and change directories to the location of the utility. Enter the following command:
<Your WSC Name> is the actual full path to the location of your Windows Script Component (WSC) file. The utility will parse your WSC file and make the appropriate entries into the Windows registry. This utility must be run for each user on the machine if they want to use that plugin.
If you use the MS Script Debugger, which Microsoft makes available free of charge to debug VBScript scripts, a syntax error in the script will cause the debugger to stop at that error. However, in general, the MS Script Debugger cannot be used to debug scripts while they are being used by STK.
Installation for Perl Users
The use of Perl as a scripting language for Plugin Scripts has been deprecated. Python is the recommended replacement language. See Installation for Perl Users.
The use of Perl in PluginScripts requires use of Microsoft's ScriptEngine technology, currently a deprecated capability. The ActiveState company had provided a ScriptEngine interface for its perl installation until version 5.18 or so; however, that version contained a bug preventing the ScriptEngine interface from working. As Microsoft had already decided at that time to deprecate the ScriptEngine technology, the bug was not addressed and later versions of perl from ActiveState do not support the ScriptEngine interface. The last known working version from ActiveState is 5.16, though AGI's testing uses version 5.14 (64-bit). This and earlier versions of perl are no longer supported by ActiveState and are not normally available.
After installing the correct version of Perl, you will need to copy the Perl module STKUtil.pm from the <STK install folder>/CodeSamples/CodeSamples.zip/Automation/Perl into a directory that is on the Perl library search path (i.e., a directory path contained in @INC). Typically, you will copy the file to <Perl install folder>/lib, where <Perl install folder> is the directory where Perl is installed on your computer. The STKUtil module exports several utility functions that you may want to use in your own scripts. To use the module, include the line:
use STKUtil qw(printOut getInputArray);
near the top of the file. The getInputArray function is a user convenience function for translating between references to an array and the array itself: this is useful for dealing with inputs to Perl scripts from STK (see Function Signatures for Perl). The printOut function can be used to print out lines of text; on a PC, it pops up a message box containing the text that you must dismiss.
You cannot use standard input (stdin), standard output (stdout), and standard error (stderr) to print out any messages. Instead you can print to a file or use printOut (or use Win32::MsgBox() directly) to pop messages up in a dialog box on the screen.
Installation for Python Users
You can download Python from www.python.org.
You need to register the Python active scripting engine to use Python plugin scripts in STK.
Registering Python
You can follow the instructions below to register the Python scripting engine for Python 3.
- Install Python.
- Add an environment variable at the System Level:
- PYTHONHOME=<Python Install Directory>
- Add two directories to the PATH environment variable:
- <Python Install Directory>
- <Python Install Directory>\Library\bin
- Open a command prompt window with administrator privileges.
- Enter the following command to register the scripting engine:
python "<Python Install Directory>\Lib\site-packages\win32comext\axscript\client\pyscript.py"
- If the command is successfully executed, the message "Registered: Python" will be displayed on the next prompt line.