Example of a JScript
" @! @- u, w) c& W7 q6 ^+ Mvar vbOKCancel = 1;
( J b' F; O: pvar vbCancel = 2;
4 e3 A0 C8 q1 D8 Fvar vbInformation = 64; . H) H$ @4 T8 D6 j m2 h4 X# I
var Finished=false; : S- z8 S$ z6 R& B6 C/ J/ f
1 O4 B6 s, C" u$ |& L
var WSHShell = new ActiveXObject("WScript.Shell");
2 c; S; D+ D& z1 G6 T! R$ G7 A( C, W9 K ' i& Z/ o8 V& W" r
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ) D/ z# S# s2 U
5 I! ~4 \- k+ M( @
simple.SetLicenseType("Runtime"); 5 z: W" u0 B2 k L
, E8 X% z5 i# y/ y
try
& f) Z5 E# ^' d: W8 I6 M{
& u% `; P+ q3 Y+ a0 D% u! A // Enter the path to a model file!
6 e$ Y! q0 ]# X: y0 W7 n- c c7 q8 f1 { simple.LoadModel("C:\\Models\\Test.spp");
2 `& c6 R8 k, n- V* z}
4 o1 T/ e g( {5 u! C0 Dcatch (e) * c9 x! c6 ]% v: i" e% I; B, p
{ ( Z* ]; o+ n# g( h! O! i+ D
WScript.Echo("Could not load Model!");
1 U# g9 D$ [+ w$ b7 _6 r WScript.Quit(); . `0 P9 x" u" Q% R/ X: `# V8 B
}
3 X7 G+ ], C1 x# ?
4 u# W+ L k; z! r! @1 {try 9 l2 L; T/ h' @3 b
{ - \- z3 ]: o& |; q& x
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
2 ~& h$ [; e7 c) ?- T1 @3 _ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); * }" g: ~/ Q0 y5 y. h4 Y8 [
if (r == vbCancel)
`( U4 ?0 D. |2 B {
% A% X) W0 F' w9 J% m( P1 q2 U2 E simple.CloseModel(); : U* t) V- B1 j( Y9 ?( Z
WScript.Quit(); 3 m6 @1 f: J" s0 S/ k1 \) [+ q {9 d
} - ~, C4 `6 D/ r9 O! N' X
} 7 S' ]; `+ q3 t& }
1 v$ a3 ^$ U2 W3 A
simple.StartSimulation(".Models.Frame.EventController"); / l) [) N" U9 y) l+ D6 v
( u, l. G# z! o8 _- E/ e
if (simple.IsSimulationRunning()) # F: l, B) m* C" _# w; t |
WScript.Echo("Simulation is running!");
8 E2 Y2 t" H$ T6 t5 K9 k
& @ f" z- E/ A// Wait until simulation is finished 8 y$ w( H1 X# h6 K. F
while (!Finished) WScript.Sleep(2000); . D+ ^0 p5 x3 f
: _; P$ E5 X4 l1 J7 i) v
simple.CloseModel();
3 l. K1 s. G* N& p xsimple.Quit();
9 Q6 b9 s2 A, E( l; aWScript.Quit();
* B8 `1 ?4 `, ~% l7 }
9 k6 x4 k5 A% a. _( t) q" E( P# Z
9 Z7 _ A& P5 _3 k; Ufunction RemoteControl_SimulationFinished()
' b2 ]5 F- ?5 O3 z{
2 E- I: J: V) T G% ^, `( g0 |4 z WScript.Echo("Simulation Finished!"); |