Example of a JScript
. b# \4 M8 u! ~var vbOKCancel = 1;
! i' j1 X- t# i1 J9 z1 j; xvar vbCancel = 2; " q/ J4 c) B7 f. i* \# ^1 Q# ^
var vbInformation = 64;
/ b* @2 R0 m' ivar Finished=false; # `( X, e& G( u3 J: n& s
E$ y2 A( Y7 qvar WSHShell = new ActiveXObject("WScript.Shell");
* t# ^" q5 F; b* Y" p0 A 3 P: A' b* ?* `6 {/ D. T3 |
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); & V3 K& i/ A, B T; G" l$ j
2 A0 e9 _9 e# Q2 J/ z
simple.SetLicenseType("Runtime"); % w; l& J. D- y+ C0 }
2 j: l. v4 Q4 H8 h( W# ftry , K" ]9 p- n! X: c: p; E0 l
{
{$ E; a# j8 d' D // Enter the path to a model file! E; v- p2 U7 t
simple.LoadModel("C:\\Models\\Test.spp"); - N. T/ }; `; G1 I
}
% Q- @: B3 ^) v! C/ K5 \/ w Bcatch (e) 2 V$ _' M4 y6 v. `# f
{
+ ~/ C9 a6 I; Q m2 u4 y WScript.Echo("Could not load Model!");
- i b2 r6 E# ~# y" M! G WScript.Quit(); 6 Q! x, U8 h# x' w [7 r" ~
}
4 K1 {) B& @% q
' |$ L7 T- X$ d' B& Stry ( i, E* ^! j# ?& a' U3 n9 y
{
9 o+ l* J8 f8 q$ _/ p+ B& ?8 i simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { + r6 H9 Y [" @3 h) p8 v9 L9 b
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ( u9 r# ?' l% x& `! j
if (r == vbCancel) & k% L) C' k. M: P9 T5 T! G0 o
{ 6 O2 X; h+ N3 [
simple.CloseModel(); . r9 T+ F; g, t: `! E3 G6 |
WScript.Quit();
* D& ]6 e7 h; p2 J. M } + ?# G$ k/ P0 m+ }4 m- m4 c0 L
}
: R) Y2 e3 r T! {/ c ( P: I$ b" P: V3 E
simple.StartSimulation(".Models.Frame.EventController");
0 C' k# U/ S) i. u& m B, s
1 t' a( U7 u, w2 rif (simple.IsSimulationRunning())
, I! S7 s( X! q& E5 D WScript.Echo("Simulation is running!");
0 | V6 M% H! ~4 b4 F7 V+ I* O % d7 u% @2 A% `. t" g; K
// Wait until simulation is finished ( s. Y4 O% B9 |/ m4 u
while (!Finished) WScript.Sleep(2000); 0 \4 J" ]/ l& z: h
6 Q$ D1 I" }* b1 P9 k4 z* z( `
simple.CloseModel(); + Q6 `& ?% t' H( t8 e7 M. i
simple.Quit(); . l# E9 a0 }1 |% F$ F
WScript.Quit(); & a; g, Q# z4 d6 d3 ]
, p* q9 K* t; b; t. ?0 \" Q 3 R* e3 e6 B; A9 b" B2 ]. M. D
function RemoteControl_SimulationFinished() : S4 P* _0 ?4 D- s/ F
{
' ?* J" [9 Q3 u* n5 D0 ?" E WScript.Echo("Simulation Finished!"); |