Example of a JScript
- O O; E" n1 l( O( l( y, yvar vbOKCancel = 1;
- ]" [ L3 J- a* H! w! ~8 ~var vbCancel = 2;
- w: k) @/ A( Yvar vbInformation = 64;
. ]4 n* i; \# V9 a2 `var Finished=false;
: g! e7 c3 y+ b: i, H- E: Z" ]6 O: U a2 Y P3 p# }, w
var WSHShell = new ActiveXObject("WScript.Shell"); , L/ Y( L% V- g1 S. k1 @( E
" n* e7 G: G6 b% }. G# z- jvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); + \" ^; \. ^7 X3 s4 w0 a
- O8 r7 h5 e2 g/ B h# F; F
simple.SetLicenseType("Runtime");
i; P9 `! c, U' Z) f, V( @( ]
4 Y* ]" D) x% k2 u+ H" Gtry , a6 v* m" w- w) \# S& y8 q
{
* ?) g" H- A* }# z! \2 }1 S // Enter the path to a model file!
9 L: X) H+ u( b1 L" a. F* Y simple.LoadModel("C:\\Models\\Test.spp"); 5 I9 J) Y- o, i) g2 \5 B
}
$ h. g: {! o- gcatch (e)
3 g0 ]' m) j% D F{
! A) p" L+ J; b- M" M& G WScript.Echo("Could not load Model!");
. q n" F+ x; {2 O WScript.Quit();
7 X8 }# l" b Z0 S6 K} # h5 |) d0 K# h* c8 m0 B( v; l2 }
3 F5 |, P# B: y7 W; w7 ltry
R4 B) v% F% V+ [; F{ ; {( G7 r. y+ B7 z& A4 {
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
4 }5 U& e: ]: O" ~( y r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
1 Z" C7 x; `: f& o; A if (r == vbCancel)
$ H$ l7 W# K2 \ {
5 \1 W ?# z3 c; t, ] simple.CloseModel();
% J& x( G+ \" j. V/ X WScript.Quit(); ' X! K6 I5 ]) B5 z5 X" M, L* r
} 7 e# `) i5 `, c l( f
}
3 J7 s; M4 M: j( }8 e0 D 1 P `$ a1 f/ H
simple.StartSimulation(".Models.Frame.EventController"); 2 }6 F+ l% E' q$ ~# ? @" e7 a
- W* h" p1 C+ E, m. [$ M$ d$ b9 A" gif (simple.IsSimulationRunning())
9 W% u* t8 j9 z: n! [; _ WScript.Echo("Simulation is running!"); 8 K' C2 ?( P# N1 L8 K2 u( d
3 b( C0 W9 e) i6 ~3 H M3 Y
// Wait until simulation is finished
1 S7 P8 E( }2 w& A! [while (!Finished) WScript.Sleep(2000);
, Q3 I" e) V( t. y" I ?; s & F s1 I9 v8 z% I) U, Q: d* {' x
simple.CloseModel(); {- B- G6 Z' Q) S# j1 R
simple.Quit(); # h2 z2 K- \2 O
WScript.Quit();
/ C8 M9 [6 _9 G2 r8 S. ^ 5 u# K0 r& F; Y! Q( s2 Q
2 e& c1 `. R/ r0 Dfunction RemoteControl_SimulationFinished()
$ q; g' m/ B3 O{
$ T7 X6 F2 G5 c3 O WScript.Echo("Simulation Finished!"); |