Example of a JScript % d+ T9 D) C0 j! u# `; X, `
var vbOKCancel = 1;
& l4 g" i( {9 w4 t1 wvar vbCancel = 2;
, Z% J8 w5 B3 ~0 Hvar vbInformation = 64;
o1 j# J9 M& r6 P$ U4 q$ D! zvar Finished=false;
Q, Y: d' F. U( _ ' ?; P' U" P1 x1 }
var WSHShell = new ActiveXObject("WScript.Shell"); 0 v7 W" U7 V C
+ @4 k0 K+ y% |5 r6 x) U8 zvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); F7 q. w3 |5 H' ~1 r0 r$ t
& O9 J6 V$ C1 c2 I" r! usimple.SetLicenseType("Runtime");
) V! N3 T6 P* q# o7 T3 B 7 Z9 ~2 z* j. c; _3 i) [8 X5 r: L
try
) R/ R* v1 V) _{
$ n* Y/ A2 n$ R; I# u8 T // Enter the path to a model file! 3 V/ M, D, d, p" g! e4 _2 m+ G
simple.LoadModel("C:\\Models\\Test.spp"); # W- f% }5 K: R! n2 [& L* b l6 |
} 8 P, P2 h1 i, j: `; D4 O
catch (e) / r9 M$ Q! L2 [" J. y6 m
{ ; f3 o+ U1 r7 z' M" H
WScript.Echo("Could not load Model!"); 0 h" R- A3 Z+ P' U, M8 S$ O
WScript.Quit();
! ?( H! D: h% m" q}
5 U) I" h1 g% Z; l. q N
6 z2 f& [8 |: @4 I0 utry @. U% A; ^7 b S. Y
{
$ h4 I' K, U; z simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { $ ]6 i% B- O) P+ z* N. X2 J/ |
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
6 A2 @; G! }' c4 R if (r == vbCancel) y' B# N: g9 c- c' G9 G
{
0 E z7 R e0 o simple.CloseModel();
1 f M3 h8 L: g. l; I WScript.Quit(); * b: C. M) O9 f7 S) z8 R- I
}
/ j/ }) i2 }+ j& E9 k; D- n}
* g8 ~6 ~5 w* K% r : E+ s' k; |! q ]2 T7 j6 c
simple.StartSimulation(".Models.Frame.EventController"); ' Q! [3 {' k- Z- U# C+ j" }
- B7 m# |; G( p0 Kif (simple.IsSimulationRunning()) # G9 J: j- { e! X; l9 S
WScript.Echo("Simulation is running!");
: \3 L n$ I! O 7 I+ p |" y2 Q' ?, U$ Z. W6 P
// Wait until simulation is finished ) I, z+ Y6 G6 A4 N/ P. t
while (!Finished) WScript.Sleep(2000);
3 M' U9 C; p- y) m) ~# G9 X: c . U& F% W$ C, Z4 n' E6 u
simple.CloseModel(); + q" a) b. a0 Q
simple.Quit(); 7 [$ G( p6 V! w
WScript.Quit(); ! q& K& N0 d" b( a6 I7 @
7 P& I5 q6 a2 L- S" D2 w ) c$ a& A% J- z/ f1 U
function RemoteControl_SimulationFinished()
" f v! B3 q ~8 h{ 2 z% |) m6 S4 p# }
WScript.Echo("Simulation Finished!"); |