Example of a JScript # s6 q; y- b/ e' s* o# y9 Y$ s
var vbOKCancel = 1; " f, ]8 P; D7 x- w* Z% |9 ] u4 O
var vbCancel = 2;
( c: E) }% O- F) V0 L/ F4 Mvar vbInformation = 64;
6 A# Z/ e: }( k" p% `% ovar Finished=false; 0 ?" j' x5 u0 q: V& V
8 k* [4 S" \5 B8 A' P
var WSHShell = new ActiveXObject("WScript.Shell");
/ {" K: U0 X1 `7 ~9 v1 [ ' \- T0 d4 d: v( f6 k n( k
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
5 a) `2 A a+ q+ M " j9 U3 W8 ?4 u7 C6 E7 `
simple.SetLicenseType("Runtime"); ! O( T: Z$ C0 Z- y- y5 j8 g/ N
' c( s; q8 H2 x/ ytry
5 Z' J+ @* F) `/ K/ @: s{ + b$ q5 ^6 Z* ~, ~
// Enter the path to a model file!
$ h) \2 B/ G3 N) ^. x. v$ C' N simple.LoadModel("C:\\Models\\Test.spp");
$ K/ b* U q% `7 |}
- V) v2 A; j: k8 S$ ?, V# `catch (e)
: P* D! y3 k# R1 O. {8 m5 b9 ^{
2 @) F& _! Z: G WScript.Echo("Could not load Model!");
/ ^% k3 o4 E0 a WScript.Quit(); 7 e; |" ~$ g% o: v" R' v- |
} / X! C" b( l4 O0 Z; [5 d
, G# D/ R6 l& n$ D# @' C/ }
try
3 E3 l1 R D- y I: F5 q, d{ + L# T8 g& }+ x& h) S9 @
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
5 M$ F8 s* [$ g0 c f r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); * H) i J, |* _# l1 I8 A
if (r == vbCancel)
$ {& b- i5 u4 M7 j( _7 m {
# ]4 e s7 S" w* ]" U simple.CloseModel(); 1 G7 Q1 e! y/ [4 A/ k0 K
WScript.Quit();
+ ]7 ?- J |* ?! Q+ o9 ?! n } 7 V H# r! N+ A- t
} ( P# l: J- h- g. I! t; t
! g q6 `; T! U5 E
simple.StartSimulation(".Models.Frame.EventController");
$ T2 G8 |5 T5 L9 G& @7 {) ] + G9 C% ^# {2 e( E8 |: J
if (simple.IsSimulationRunning()) 2 W5 o# ^, y& ?* b. |: c+ [5 N
WScript.Echo("Simulation is running!");
: {' [- X0 g6 d, I7 E; l 3 S1 t% I. b" j
// Wait until simulation is finished
3 [. s2 x! B6 [+ b+ ~while (!Finished) WScript.Sleep(2000);
( U% ~- ~3 {; A: u7 o5 h 7 T) u5 T* i; @
simple.CloseModel();
1 v4 s* x! A* i2 dsimple.Quit(); 2 t# `- p+ V/ Z7 P6 _% S
WScript.Quit();
2 I$ s* N4 p0 a& ^( Q+ W* m 9 I5 `0 z0 A! r6 m" P! M; O+ Z
3 t( c: h g! J! [/ z
function RemoteControl_SimulationFinished() # I$ I6 P' y' q% I4 ?# C
{
: e* F$ T8 C7 w o WScript.Echo("Simulation Finished!"); |