Example of a JScript " g5 O3 \; s/ R' f3 q. I) g
var vbOKCancel = 1;
" O; N# z0 d( p% Mvar vbCancel = 2; % ]. r% L5 [3 |; X
var vbInformation = 64; # a3 `! g. x7 ]- @$ `; S! G
var Finished=false; + A7 l6 M1 ` D4 m" G. u( a8 _
1 F: G* F/ `& M( o/ ?) R
var WSHShell = new ActiveXObject("WScript.Shell");
! }/ w. b& }& f* `9 H; Q- U 6 Q" f# Z& W" e7 _6 R* S
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
& i8 W4 p+ b- [: E ) a9 e. P) H8 n; w* P5 L" X
simple.SetLicenseType("Runtime");
8 T: [% q/ ?: b( V
6 P; U* `+ Y( `0 }try
4 P9 ]& f! F0 s" x! e{ ' E! K6 o9 ~, G: W+ I
// Enter the path to a model file! 2 E) t6 x( E* t; k4 H
simple.LoadModel("C:\\Models\\Test.spp"); 2 D5 o. ?+ d* z
}
6 |6 I- b1 v4 A, b1 U" c8 Jcatch (e)
8 E! R+ c% r: N! `7 m{ 7 r Z9 m, [5 @! W0 r
WScript.Echo("Could not load Model!");
+ P$ d$ g. M& ]8 u$ X( ? WScript.Quit(); : e/ k/ i: X5 w4 I
} 4 P- W7 U5 b; `$ w
6 ~" [2 z, y( T' Q$ W
try
p: Q0 b1 {2 f- n( V% _{ % P, b* |! g! H0 A$ T$ I
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
9 K5 G) H5 S0 P1 U r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
`, h' r' J2 z- f if (r == vbCancel) ; Z; O o8 q' k
{
4 f) w$ ]$ {- f' W simple.CloseModel();
4 T1 X. `6 d/ D% y. L1 c S WScript.Quit();
$ d9 q; m1 u- }- w0 t }
. ^4 ]+ W. N5 ~6 w: [}
1 ~+ D9 ~8 Q9 a% e% Q' v
0 q: s, X- D; [& f2 o* V) Lsimple.StartSimulation(".Models.Frame.EventController");
3 [4 o3 e" e1 s! U( ^, u
7 N# u% ~* I/ [0 Nif (simple.IsSimulationRunning()) # R2 |2 {: h# J" ]6 E1 H
WScript.Echo("Simulation is running!"); ; h3 n) P+ M. R( t& m, {1 y
7 a+ p! u) P% l* U// Wait until simulation is finished & `/ {& ^# [* Q
while (!Finished) WScript.Sleep(2000);
. O3 o: f* e2 ~. ]+ m+ s
8 F0 N$ V' [# T2 J. v& ^simple.CloseModel(); : V3 x7 }8 l0 N
simple.Quit();
- a) o+ Q9 T4 X `1 BWScript.Quit();
, \5 v0 |+ D! A% x* R' R - O" z* [0 \! t6 I7 s0 _9 c- X$ F
- N; F7 S3 t2 ]9 |5 M4 Bfunction RemoteControl_SimulationFinished() 3 ]4 R: U A8 j( ~2 ^
{
( c) O Z5 x1 n, ^8 O2 D- K1 a WScript.Echo("Simulation Finished!"); |