Example of a JScript
1 g x- n: d4 ?2 T' }/ i* Hvar vbOKCancel = 1; 2 M* x6 D$ O6 n# J
var vbCancel = 2;
- U! U' F/ a- @6 d3 U1 G! h3 wvar vbInformation = 64; 5 [* o3 u+ u/ Z8 h+ S |
var Finished=false;
( N" w) Q) H( U; C% g# r
( @. P/ Y9 A2 v$ R% b4 j- Q4 Zvar WSHShell = new ActiveXObject("WScript.Shell"); # H! ]0 r2 t0 l. C# ^& H- n# V
3 a0 x( {8 S: E) ?. D+ l# [' dvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ; e8 Y+ e# e$ i B
; n0 n4 s4 I% F- ]8 }% j3 `
simple.SetLicenseType("Runtime");
. T# P4 G+ T& |4 C# U
/ }' F# q+ K1 gtry
5 X8 S" d- R7 B. c6 w, _4 A2 f{ ) ~3 L3 y- M* f7 Q# W3 C, B( Q' }
// Enter the path to a model file!
" B! H8 u2 c$ C3 M# y simple.LoadModel("C:\\Models\\Test.spp"); , U( Q* r' P4 R4 s5 |3 W
} 7 d( u( @& b I& w# g& V- A ~. Z' u
catch (e)
G4 k) G, P3 I) s: K1 B{ 4 \) t* Z B2 v, @& m
WScript.Echo("Could not load Model!"); 3 X; ]! k B. M7 @/ P
WScript.Quit();
( a5 P0 R, C5 b} $ y8 ~% Z5 t) y( L4 a
; f% r S, M/ ^
try % }8 i* C: G& P4 P: n4 \+ x
{ 5 \) a% n [' m# t& w4 k
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ; J3 y) g: _$ i+ f
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
3 e! M6 G: W4 X; t1 T! g. q4 S if (r == vbCancel)
- R' z/ F! U' V( A- P& l6 X3 ~, Z { 1 ~# l; f" q* C
simple.CloseModel();
- S! O" L2 a2 J- N# { WScript.Quit();
8 t9 I% K7 t9 y+ y9 \. _# r } 5 @# ]4 T7 m' m
}
v1 V* d0 W2 @1 h4 M/ a/ c
1 v q9 \! l6 {" Isimple.StartSimulation(".Models.Frame.EventController"); 7 F' y: e; {6 @. q2 j+ ~
& t7 c* w+ V9 a" f3 {' Vif (simple.IsSimulationRunning()) ' O' H1 E8 r; \& p. c( P( q
WScript.Echo("Simulation is running!");
' q* a* i' _( y& u6 p! A4 @ # U, [# `# J) S4 c- p
// Wait until simulation is finished : h$ p/ j8 K9 [) G; N9 ?
while (!Finished) WScript.Sleep(2000);
2 _: R) E" @# Y0 P- t* y- J7 | 7 [6 k2 f% M+ O4 d; Y
simple.CloseModel();
1 V2 M! h6 s% Gsimple.Quit();
7 @' W Q3 T, o. B- pWScript.Quit();
) y7 s9 h5 {) v. b 6 w* h2 U4 d% m. j; B7 D+ h
% V/ _( R! ]1 h6 _& p: D1 K b
function RemoteControl_SimulationFinished()
% d* }. K* }) I0 r. D |4 y( B{ 2 l. [9 s6 R2 r$ P
WScript.Echo("Simulation Finished!"); |