Example of a JScript * H% T8 [$ F, ?: u% j1 i/ _- g
var vbOKCancel = 1; ) d7 J) ^. ?! w9 Q( w
var vbCancel = 2; 7 t" m6 b I& Z e) q& o+ m
var vbInformation = 64;
6 i! u# c8 X' U2 j6 O" E( b0 h' uvar Finished=false;
9 S) e2 D# I- {; Y; |2 L / `3 p# f1 K' D. H: B( R
var WSHShell = new ActiveXObject("WScript.Shell"); : `( [& p2 F0 _6 v. c& ]
' P, B' y7 F8 L/ q6 V" @6 E
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
' {1 m* o! V: {2 Z' B- @$ p - L1 S7 b% {; B: l( }% H, T* y
simple.SetLicenseType("Runtime"); % D a+ {& `+ e W m1 Z. A. E
& t o# _, \: Z/ S0 K' M' d
try
9 {( V: d a8 \' F8 x& O{
% f$ H: @1 _2 d // Enter the path to a model file! 0 d) M# r$ n; Y% R' n# V
simple.LoadModel("C:\\Models\\Test.spp"); - o& z5 t# m8 }8 I9 ?
} 6 t1 B. }' P( s" Y* G" G0 g
catch (e)
( f l" O. z! C w; U{
, {& f2 y2 j/ s; ` u9 x1 z+ j) J; V WScript.Echo("Could not load Model!");
9 {" M; M( g1 F' J WScript.Quit(); # p& d! B* x7 u1 R9 ?
} 7 H" Y5 J+ }8 s5 W, }' Z! P7 G, D
) Q! `2 I2 s( ~; u& b `/ k' b. Wtry
_+ |/ t+ N/ {; ~% {1 F$ w9 t{ ; `( D, x4 v, W0 S( F
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { u9 i; ~+ w4 X% M% }
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
$ t6 W0 I- \. a6 h! y( W if (r == vbCancel) ; m2 Z, j3 r" E
{ ' {4 r9 ~: r9 r! c8 ^- K; B
simple.CloseModel();
" x! Y; \/ K# p WScript.Quit(); # a+ j0 L: v* P; a
}
1 Q: X- e& d6 Z8 a( \' b}
% c4 w4 `, y1 i) x " D( B1 a5 m0 j* c
simple.StartSimulation(".Models.Frame.EventController");
- U& p1 r$ e0 C7 W: n. p' E6 T! V3 h4 y
* l# h. T+ x, `* }. U6 ]: u jif (simple.IsSimulationRunning()) 0 ] X' Y3 ^2 k5 J7 w/ k
WScript.Echo("Simulation is running!"); % g9 i) v& w6 r% Z& X p8 U5 y
, o8 T/ D w$ K G
// Wait until simulation is finished 1 i3 s1 P2 h! \6 p3 _6 m# B# ~8 Z- n4 X
while (!Finished) WScript.Sleep(2000);
`0 w6 S% `/ k+ w/ w & S* W8 n3 z' c& T3 r" m2 q6 g
simple.CloseModel();
% R4 O- k: S5 M3 }6 i$ M. L( lsimple.Quit();
|2 F# ]: J |) D. W2 u7 uWScript.Quit();
7 L* E& O6 @6 ?
d# q6 e x4 d5 U2 X & u% e) ]4 O0 P- [- h! V& S: a
function RemoteControl_SimulationFinished()
& n( T3 x1 T$ N6 S{ 1 h1 o8 S/ P1 z s5 {( j
WScript.Echo("Simulation Finished!"); |