Example of a JScript 9 V. ?6 ?* b9 n ]) u- M# N
var vbOKCancel = 1;
# G9 }& C/ j; ~var vbCancel = 2; + g" n8 ?9 S6 J* Y2 N
var vbInformation = 64;
2 H. r7 z) l- mvar Finished=false; 2 ~ E" g5 Q1 p# ?6 h0 g- z5 x5 D
: \& z4 j# G2 H0 s, |1 J) x' N; @var WSHShell = new ActiveXObject("WScript.Shell"); 2 Q- X, n9 w, n& Y+ U- r9 ?6 w' z
; r1 T$ ?0 [* @, K) A: W) K7 Z4 j
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
) |: J: A2 z ?9 s( l4 b w- D9 J/ {: u9 }. m! D& x
simple.SetLicenseType("Runtime");
( K! S" Z9 I/ O6 p) @ / y, `7 @ }& g* H) R( |
try
% Z l" o; h1 c+ }8 @{
# _7 G6 `5 M" @; e // Enter the path to a model file! 0 x1 q& N# O, D+ u/ w7 e
simple.LoadModel("C:\\Models\\Test.spp"); # v" z" F; c7 M7 q
} ' k4 K7 }6 W% o; f- C s- Z
catch (e)
) K B4 p& Y; k. P( w) z/ T5 L& T{ % i. M9 ~: K. [, {
WScript.Echo("Could not load Model!"); " E8 X& G$ K8 a+ h* z: W, I7 }
WScript.Quit();
$ j {, E9 K( M/ f$ A} - v2 [' u5 ^9 a9 v+ p( F& H
5 s) U" J+ o. d3 G2 _, }2 ntry 7 n* |6 N2 k9 l; e2 f# c
{ 0 ^4 W% d' l0 q
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
5 z2 L7 M1 _: `/ O5 \ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
& E$ L. E+ A! B0 \& f, P+ i/ ] if (r == vbCancel) 3 M7 a/ h' w3 I; P
{ 5 n2 l# J7 N! U" B5 u
simple.CloseModel(); ; h* j0 c3 v M# u3 J
WScript.Quit();
0 |6 b( i' H; f/ @7 A } ' l% T- V$ e: n. x7 e7 t3 n7 k
}
. A2 y4 \. c6 s* Z2 c X / ^! H5 |; d! B; b, h8 V
simple.StartSimulation(".Models.Frame.EventController");
+ d4 p2 D0 M5 O; ~( o g ( l1 T6 m% A" Z6 D
if (simple.IsSimulationRunning())
) V3 ^" p) T c3 Y: x; C X$ L1 i WScript.Echo("Simulation is running!");
* K6 M3 F) a) Y" i ' s& p7 A, T0 A- a
// Wait until simulation is finished
. [" ^, I( _0 K3 Wwhile (!Finished) WScript.Sleep(2000); 6 D- U. ]% \( N: M9 X. y* \' ?, n
. ^/ l. q8 @8 ~2 m4 A* S# _! _simple.CloseModel(); ) { k$ @& z: q. Z1 M" f1 ~
simple.Quit();
- q6 i2 a+ G2 C0 s7 g: o0 P! HWScript.Quit(); 9 ~; I/ {5 P, q [4 M1 Y
% V4 s- l9 o! u $ E# o# }% K8 J# W7 S/ Q
function RemoteControl_SimulationFinished()
6 I5 m! Z3 P7 l, r7 g* x{
; T9 Y" D0 _# ^9 `9 ?& ~2 j WScript.Echo("Simulation Finished!"); |