Example of a JScript
9 T: @' Z( R& S1 l- kvar vbOKCancel = 1; " [6 | T" N/ L8 ]; k
var vbCancel = 2; 6 g$ o3 I V+ C! u8 b. U! T
var vbInformation = 64; 6 \3 N/ L5 `' q& `# ?* v, W" Y5 [
var Finished=false; , m) `& j# O' {* E' P: n
: S# d$ V8 u( g, h; ]+ n) Lvar WSHShell = new ActiveXObject("WScript.Shell");
$ ?* E& U4 `0 c( @7 ~ 8 J6 X6 p$ ~! c+ G: o8 t
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
# i4 S# V. k! _6 p& p
5 Y. {) K3 Q B( z& \, S7 U4 Asimple.SetLicenseType("Runtime");
( `, {' W+ {6 E& W$ {/ S
. ]% S5 ?0 Q1 H$ n+ N% ?6 {0 ?6 K( Ytry
- w# d5 d1 g# _( A4 d6 K$ N$ k{
; N/ F4 u/ F; T. B // Enter the path to a model file! 3 f F( U- B- a o) R2 L
simple.LoadModel("C:\\Models\\Test.spp");
3 e: n; p2 z. U}
$ c7 N% q9 N: \% X8 v, j0 C3 `catch (e) - ?# x7 _( b# v; o4 y$ v
{
' Z1 m; c7 {' M+ I7 y WScript.Echo("Could not load Model!"); 0 R6 ]' o4 o! `1 U& K2 x' k
WScript.Quit();
% O6 S% g) E; e. G+ G5 \4 |: t}
2 _: l$ y2 O( L/ |# i
0 @; I( }: h! Btry ( ~: g" }6 J2 |0 r. O# [/ d
{ ' @+ @0 ~4 _" s# P$ d
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ( T1 k+ f/ L5 G2 V: w( }- m
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
. e" l6 ?7 Q7 ^+ | if (r == vbCancel) # Q3 P6 G' n% }! D( x P
{
8 z. ]7 @$ S* n simple.CloseModel(); + T2 {2 n5 d3 E0 |* T& C8 d
WScript.Quit();
! R* ^7 P) r, X# ]+ G+ W, U } & M4 E% R2 d6 G. v
}
/ h! J: y0 x" w3 H0 V v
8 Y- u- L7 ?( |2 t5 ^; X* }% s; ysimple.StartSimulation(".Models.Frame.EventController"); 6 I T* D9 G; o8 x
{/ C8 r4 A9 u/ f
if (simple.IsSimulationRunning()) ( t3 g7 A9 u% q& ?: }& e6 z
WScript.Echo("Simulation is running!"); % O- J+ }# `" F, Z: Q, X( n* {4 c
% [8 h# w1 ?6 x6 \4 `2 z// Wait until simulation is finished
7 t5 r. e/ y g/ B" ]+ j) Mwhile (!Finished) WScript.Sleep(2000);
3 g4 C' r; y; U6 Z$ q
; x7 q7 d7 K$ J2 U8 E- x& n7 |1 s% ssimple.CloseModel(); ) ~; `8 K7 k) g1 M
simple.Quit(); 8 q% v/ R3 D- v2 e- ~& d
WScript.Quit();
) l6 ~' o( @9 H$ C7 ]) T4 ~ 7 Z/ E( O; ^ m4 R
; \! K9 m% f0 E$ V5 ffunction RemoteControl_SimulationFinished()
3 d6 z: R/ G% ]+ s{
7 t3 k p9 k# U$ @: I/ d$ ]; a WScript.Echo("Simulation Finished!"); |