Example of a JScript
% x4 ?. j! l! b. X/ T" l% Vvar vbOKCancel = 1; 0 H' @3 \; S: _/ |& c
var vbCancel = 2;
' q4 u# I& X5 V8 a: Zvar vbInformation = 64;
# c7 o2 ~7 J3 Yvar Finished=false;
. R4 ]/ ?3 |; ~; b
9 x2 F- l- t: g9 Tvar WSHShell = new ActiveXObject("WScript.Shell");
3 S! m9 m2 Y9 I 9 [- x5 I% y$ F2 X
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); , n& H X4 N w" P% T/ I! i/ V
$ @5 w7 Y9 f9 V, J# L+ }
simple.SetLicenseType("Runtime");
" O' p9 r* H! S0 \( p 6 M4 [- J0 e* k6 `3 ]: q+ ]
try ' B6 B3 _8 d1 [
{ . b/ _/ P. J2 [
// Enter the path to a model file!
& ^! P7 |' f5 W7 J3 o simple.LoadModel("C:\\Models\\Test.spp"); T a% ?3 g6 r# h. ^6 W& q" M
}
/ A( I' ?; B7 Q3 ncatch (e) $ f2 o0 A5 E, W
{ / @0 d9 w) [+ |
WScript.Echo("Could not load Model!");
4 Q8 c9 K n+ `1 ? `$ F2 t. ?! r WScript.Quit(); % F: ]0 F' w0 q6 d
} * \2 R% k- j, H
! b( n6 V1 F& c2 `% E" X4 p
try
0 w$ l% c4 j U! m! Q{
8 ^) l) o4 g2 d) r+ X7 o% L simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 5 F# @2 Z! w; f0 u
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 9 P: O- Y" g* y( A) W
if (r == vbCancel) 8 T) @# w; y0 |7 y
{
8 e2 ], |. H0 C# s$ q9 _- |3 h simple.CloseModel(); 1 |- C. V. l9 q C" K
WScript.Quit(); 5 v% Z( Z1 _/ @7 O" C4 W/ W. c
}
$ J! P, F/ E+ `! _) Q* p# A}
, t m0 Q* s- ]1 }$ L% g ! h3 J! N$ Q0 m3 u
simple.StartSimulation(".Models.Frame.EventController");
' ^) `2 }& @$ |2 @5 E
9 i8 O) c; x b% { x7 yif (simple.IsSimulationRunning()) 4 X6 \/ W2 c+ ]
WScript.Echo("Simulation is running!"); 6 x# }: g. [8 v& f8 N, k$ K
3 U4 ^% @" Y7 w: B3 U6 T0 h
// Wait until simulation is finished % `' B4 v- T; w$ {; V$ x
while (!Finished) WScript.Sleep(2000); 5 _, |6 L3 g( p& P8 p
$ N& n: }& }' R1 c
simple.CloseModel();
7 C* X9 N* G v7 I4 \# I3 |2 ssimple.Quit(); + n v3 t1 r: j. `& I
WScript.Quit(); ) k/ R: w; h& O( E7 w0 |7 X2 D& L
2 B8 v" ]1 w6 _2 x& r3 l " n; u2 X8 D4 u0 F* x* h
function RemoteControl_SimulationFinished() 8 w$ N3 g2 ^4 _) |
{
( H1 t& m8 B" B/ t* ]& L WScript.Echo("Simulation Finished!"); |