Connect Code Example


/*************************************************************************
* For Customer Support contact Analytical Graphics, Inc. at www.agi.com *
*************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include "AgUtUnicode.h"
#include "AgConnect.h"

extern "C" {
char *AgEAppName  = _T("ConnectExample");
}

int
main()
{

char        *connection1      = NULL;
char        *initFileName     = NULL;
static char  connectName[256] = _T("localhost:5001");

AgTConReturnInfo returnInfo;

static char  cmdString1[256]  =
{ _T("Load / VDF \"{Your install location goes here}\\Data\\ExampleScenarios\\Intro_STK_Air_and_Ground.vdf\"") };
static char  cmdString2[256]  = _T("AllAccess / ElimDups");
int   i;


/* Initialize Connect */

AgConInit(initFileName);

/* Open a connection to STK */

AgConOpenSTK(&connection1, 0, connectName);

/* Set verbose and ack on */

AgConSetProperties(connection1, (AgCConVerboseOn | AgCConAckOn));

/* Begin sending IPC Commands */

AgConProcessSTKCmd(connection1, cmdString1, &returnInfo);

/*
* The first command, Load, returns no data, so no need 
* to free memory allocated to returnInfo.
*/

AgConProcessSTKCmd(connection1, cmdString2, &returnInfo);

/* Finished sending commands, close the connection */

AgConCloseSTK(&connection1);

/*  Print out the results of the AllAccess command */

for (i=0; i < returnInfo.numEntries; i++)
{
AgUtMsg( AgCMsgForceInfo, AgCMsgNoWait, AgCMsgDispDefault, AgCMsgNoErrorCode,   
        AgCMSourceLine, _T("Return entry %d:\n%s\n"), i+1, returnInfo.returnList[i]);
}

/*  Wait for user to respond */

system("pause");

/*  Clean up the Return Information, freeing any unneeded memory */

AgConCleanupReturnInfo ( &returnInfo );

/*  Free remaining allocated memory in the Connect module in
*  preparation for exit
*/

AgConShutdownConnect();

return (0);
}
                        
                        

STK Programming Interface 11.0.1