Example of a JScript " I' S% k; O$ k @) h# }
var vbOKCancel = 1;
/ m" O- a; k) f! ]var vbCancel = 2;
$ Z/ v. G$ n0 t8 j3 h+ {% }var vbInformation = 64;
6 r& a4 i5 l$ ?4 e% S& t9 g) Dvar Finished=false;
9 ~" P/ d0 M& m- e
: a" w) ] c1 M2 p. W3 \var WSHShell = new ActiveXObject("WScript.Shell"); ! [7 X3 M8 N( Q0 O& c
, P$ `: a6 W, _2 Y5 d5 G
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); * |3 _' F% h1 R( p" O1 L
+ T+ P3 X( H6 ysimple.SetLicenseType("Runtime");
# T+ G* B* ]% D( L" I% x( S6 f& [
6 o) N$ Z- t t! @% c7 mtry ! y/ Q' p- R* ~$ v
{ ( J7 K2 A" i- V/ V3 X
// Enter the path to a model file!
, R5 K; C+ j$ k' Y0 h4 v simple.LoadModel("C:\\Models\\Test.spp");
( U6 L& H: j: Y}
' F8 }$ C; S, Ucatch (e)
6 |$ L5 F; d! s5 Z7 i) l{
& L5 U% ^% X7 ]% q# d$ u3 M# ] WScript.Echo("Could not load Model!");
) P- m) C. c, t$ \7 r WScript.Quit(); 8 s0 W4 g4 Z: p# h8 m
} * x4 V& X6 Z$ I. ?& t. p( P- j
p$ f0 ^( |0 O( M" P5 V. I) r* x
try 3 l: w1 G# T: E8 c
{ ! d" \' [7 Z# X
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { # O. T2 k' j* u! G
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
" W/ _5 r7 U* _* ?9 V( a' T: F" X if (r == vbCancel) 8 q: a) l9 j: a& q/ `3 F
{ $ N$ o( k; d5 s4 B
simple.CloseModel(); 4 H6 m: c6 c6 B
WScript.Quit();
$ x1 K8 K+ ?: S# C5 ~. `# u }
: U; j; p& t T' |* c}
1 F' P% N2 R0 U: ~3 ]$ d* t0 V
0 B5 g, O1 c' A( A% o1 Bsimple.StartSimulation(".Models.Frame.EventController");
1 T- m1 {5 g% K; t$ `: _/ \! {8 G & O; f- w% N/ h8 i s
if (simple.IsSimulationRunning()) - o( q) H1 V' j, a5 q) Q1 s
WScript.Echo("Simulation is running!");
& n5 {+ P5 q- T) t0 x ; R* \5 a; G! Q) G# E" f
// Wait until simulation is finished + s; c& _4 A7 C& e- |( \: u
while (!Finished) WScript.Sleep(2000); 6 g7 s/ F8 n1 i5 h
5 t+ ^4 U& {4 q1 @7 w; k/ \' P
simple.CloseModel();
6 _* o8 P" c0 ?4 zsimple.Quit(); $ C4 a1 o/ N3 i3 f0 m1 n
WScript.Quit();
* W0 }- w8 q6 p1 X) z - r/ e( t% m& j5 v* a
) \" \% r% L$ |( y
function RemoteControl_SimulationFinished()
0 u+ w/ K& f7 S7 k; Z{
) `$ a, @; `' r8 n5 t2 U* K. F/ d WScript.Echo("Simulation Finished!"); |