Example of a JScript 2 f- z& W( w* o7 b; b. X/ ^ Z" E
var vbOKCancel = 1; 8 u3 [8 w; `1 @1 w/ Q; d, T6 D
var vbCancel = 2; 3 Y I2 P7 G: S4 l( R9 g. q8 }
var vbInformation = 64;
6 g4 i' M0 o& i) e) O2 }! yvar Finished=false;
. [2 Q0 u7 Z3 i+ ~ m0 d* D" e 7 _$ e0 r/ _6 ]' Q8 I
var WSHShell = new ActiveXObject("WScript.Shell");
. J; [4 D$ V* d* P * d" O, [( n9 I! q8 t5 M
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
! P% o5 @ \+ D2 y% E0 r9 o* a. B
) L6 V& z f) \ `+ A" zsimple.SetLicenseType("Runtime");
9 A9 ^% X4 @7 @/ S2 |3 x& w
* V' E; ~* B# \* r8 o8 Z: itry $ l) u# S. ?1 A$ `8 @
{
) h2 O& v- G9 R+ e // Enter the path to a model file!
" z1 q; O% k T: O- F) H, L% [7 z simple.LoadModel("C:\\Models\\Test.spp");
! j7 O" W& e9 j}
, i; K$ P- y; s" U& S) V3 zcatch (e)
2 q3 s! [( A! f1 @. D9 h{ 2 T& ]% j0 o5 N) x0 o# ~8 X& k0 V8 |
WScript.Echo("Could not load Model!"); . m+ c& H) K: P% Y3 P' Q
WScript.Quit();
- w9 w6 n ^$ ?}
- }4 n! g0 u( Q# i7 Y7 b
( f- ^2 ?" V1 f. w: A! @try
, ]# }8 D0 y/ N# f8 V9 _9 j{
/ P+ Q. s$ L; g' O simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { # u3 c6 Z, F6 K/ B! D$ S
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
$ v, J S, N1 D1 ]- B. y if (r == vbCancel)
- s" r% r/ \# W/ }( f& ~5 K { o$ ^3 P! U- _3 }
simple.CloseModel();
; [ J. ]: y+ n% F- |. N$ a3 f) a WScript.Quit();
' m$ Q2 q( b. t# Z2 ^1 L" e }
& n6 p7 R, }: D* n" m. \6 ^0 j} & H' n5 z& h( P: H( T; I5 i! m
2 h0 m& S2 h2 B1 f1 A$ w1 }
simple.StartSimulation(".Models.Frame.EventController"); ' A2 E% H' |9 l, J9 Z; L4 H+ `
4 A- w3 h+ K+ S! e/ K( |
if (simple.IsSimulationRunning())
; C3 z1 P1 X2 P WScript.Echo("Simulation is running!");
8 m1 p S0 g R9 M9 Q' J
+ [: T4 c+ d. x& R7 P// Wait until simulation is finished % b0 B( E5 Y5 E6 g% u1 f* o% z
while (!Finished) WScript.Sleep(2000);
% Z! k1 q& Q1 D7 s( A 7 J) [; V) Z1 U! |$ p$ z
simple.CloseModel();
/ |2 p9 b( Q2 osimple.Quit(); l( F+ p$ J4 Y+ d0 ]0 o* k* F
WScript.Quit();
3 b4 G& u# D! K; k3 O: I
6 L0 P5 b( g1 u8 N L
+ X$ |% T3 ^6 S4 x: efunction RemoteControl_SimulationFinished() & ]/ {1 P& y6 ` P1 v/ O
{
! Q9 T& i% N$ l" p4 n WScript.Echo("Simulation Finished!"); |