Example of a JScript " h% R$ ]; a# f w; Q0 a
var vbOKCancel = 1;
) w( X( V. i# S/ D* A ^var vbCancel = 2;
! ^6 d2 N3 }4 Wvar vbInformation = 64;
( D4 g! ?, B% V: H/ f2 C' Y6 hvar Finished=false;
3 O" P1 c/ T6 a+ Q! z & k- L% g/ g! R5 R0 `% n! K1 Q$ R: h
var WSHShell = new ActiveXObject("WScript.Shell"); - o; t0 V) [/ g1 ^. }$ g; }
- ~2 G7 [1 ` b6 Z: Q
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
$ a% v" P% ]8 O 9 {1 R+ d# Y; B7 b, ^. T3 a
simple.SetLicenseType("Runtime"); ! |: c) _! ]7 q1 y1 o
! b& L9 q: p! c) Jtry
' b# N4 v! D6 s: K& w# \) J1 w: V$ A{ , I9 \$ ~" i1 c1 `' M
// Enter the path to a model file! 6 o% t5 x8 d) }
simple.LoadModel("C:\\Models\\Test.spp");
) U P0 g4 e5 O% B `} $ [; m- f* ]" i# o' ^- Q1 K9 f
catch (e)
0 S( p$ Z* E* r f$ S) |0 w{
' B# X# q) `; [* d! L# H8 A WScript.Echo("Could not load Model!"); . ?# c6 Z3 X, l- Y: Q a, j+ y7 M
WScript.Quit(); : t) }8 _5 R H% i7 S0 P
} 9 d! s, M* F, l- v; ^, B! i
( i `3 G5 [7 s& W3 J* x, Z0 Q/ u
try " a. N$ _: I- |$ }
{ * k( K% |$ H: D4 d% A0 x
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { / T8 T9 ~* T* f" }$ Y
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); + Z7 m) H) I9 Q8 f: a6 m
if (r == vbCancel)
6 b* c) v1 p1 [5 W { 1 x3 X/ V3 g) P& U. X
simple.CloseModel();
* D0 L4 s* k4 k) R" v+ j WScript.Quit();
) N6 k/ B: }' L/ z }3 j/ ~2 f! t" J } & H& }* @ y* g5 G' ~( a
}
, J c/ p, w9 v6 }, { 2 r3 a; r7 @; H i/ q' c4 i
simple.StartSimulation(".Models.Frame.EventController"); 9 n+ a' ]: D1 [5 W7 p; t/ n
8 R& ]' I# ~, U! ]9 H9 ]5 t
if (simple.IsSimulationRunning())
9 l6 K6 E$ V0 R, w4 n3 j WScript.Echo("Simulation is running!");
5 s8 \/ Q6 _, H. F6 {0 F4 S' H" c! F
5 f& F! _ Z v* l0 J1 ~// Wait until simulation is finished * J1 |7 H" G5 G1 U; t" g- F
while (!Finished) WScript.Sleep(2000); " w2 e: h( z6 M
4 e- t$ n4 l6 ?8 i0 K/ c
simple.CloseModel();
3 t; T6 `2 S7 V2 psimple.Quit();
) y7 M) D6 f) G' u* yWScript.Quit(); 3 D. N! o' h* M! O) `* x8 o
! @$ G/ j* b, \0 H6 j# ~1 o : i) }: V8 u1 {, W$ c; J
function RemoteControl_SimulationFinished() , D# V3 Y7 @& f; }" L
{ % t" V1 l' B* K
WScript.Echo("Simulation Finished!"); |