Behold... the Power of Perl.
- Jun 12, 2017
- Article
- Developer Tools
Have you ever laid awake into the wee-hours of the night and asked yourself "Can I use Perl to integrate with STK Object Model?" First, you need more help than a simple blog post, and second, yes you can! Although C#, Matlab, VB.Net and Python get all the STK/Help Code-Snippet glory, you can use Perl with STK (and not just for TCP/IP connections). Why use Perl? Well, beyond the obvious $, @, and % (scalars, arrays, and hashes), and the sexy; line endings, Perl is simple and quick (you can write a Perl script before someone opens Visual Studio and creates a new project!). Here's a simple example...
# just a simple example of starting and controlling STK #
use Win32::OLE;
# use existing instance of STK if already running, else start new #
if (! ($STKapp = Win32::OLE->GetActiveObject('STK11.Application'))){
$STKapp = Win32::OLE->new('STKX11.Application');
}
$STKapp->{Visible} = 1;
$STKapp->{UserControl} = True;
# do stuff in STK - using CONNECT commands or Object Model #
$stkRoot = $STKapp->{Personality2};
$stkRoot -> ExecuteCommand("New / Scenario MyScen");
$stkRoot -> Isolate;
$stkRoot -> UnitPreferences -> SetCurrentUnit("DateFormat", "EpSec");
# Exit STK #
$STKapp->{UserControl} = False;
You can find additional examples in the STK FAQs and Code Examples.