Example of a JScript $ f1 j4 y: u( f* v2 `9 b
var vbOKCancel = 1; 7 D( t0 J2 B: A8 n/ g9 Z, u
var vbCancel = 2;
8 P7 Z$ \+ _) N& W5 P2 gvar vbInformation = 64; . {0 M( e1 d/ a7 H, E1 a3 N
var Finished=false; ! z% w0 A6 T8 Y6 R2 G
! v) x& Z8 I9 ]" wvar WSHShell = new ActiveXObject("WScript.Shell");
0 q! M& i7 F! f' M# J x- K
2 [1 N! s# f! l$ u5 q" s) mvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ) E- j& r2 _- J* z6 f, w
, G. b" H: X) D! _* {simple.SetLicenseType("Runtime"); 5 v$ Z7 g' K$ T3 a' Z
2 }$ k+ R( U$ @5 h$ X* jtry
, L% N5 L% P2 s1 }% ~9 B1 W{
0 N% X2 M0 Y: q3 g6 I# p0 l // Enter the path to a model file! 6 z0 b/ _* ?+ v, C5 |
simple.LoadModel("C:\\Models\\Test.spp");
4 P( @/ {) ]% k6 g- z0 O}
7 B4 L4 v8 `$ H$ U; kcatch (e)
$ V# X! Y; v( b: K4 R& \1 Y2 e1 s. S* f{ * T0 Y. s5 V+ H
WScript.Echo("Could not load Model!");
b7 r1 X3 ?+ `" R3 ? WScript.Quit();
" b k: b* n2 l6 q) s1 t3 e. t2 ?}
# b8 o* ?0 W, _7 x( ~
, b- z& e& N$ E: U2 Qtry ) v* J& c2 r! Y1 G6 }
{ ' E: q0 Q1 l* O5 ~7 Z# z
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
7 w. s" u: B5 A* m, t6 b+ T r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); + s# n6 V' I( Y6 ~" ^* s; X
if (r == vbCancel)
9 D2 h3 g: i; [* d3 X+ ~" E( c {
4 _5 i2 L, v D( S) d/ w# I; Q" a simple.CloseModel();
8 b" [7 Q' B( ^4 X, [& }! X. H WScript.Quit();
5 P2 a) _; g8 G; {2 p }
! K7 ^0 r! m; w! T5 S} 7 |: k5 x- }( m- a; {
2 p/ y1 c* N5 ^3 d/ G
simple.StartSimulation(".Models.Frame.EventController"); & L- S6 n& c( q$ \0 E5 u: u/ D$ j
* c# u9 N9 y8 R; X0 J, Q
if (simple.IsSimulationRunning())
6 A' Y: [2 P J: c! R t6 M WScript.Echo("Simulation is running!");
2 }$ `% ?7 T1 S4 Y( A3 d & O9 c* d3 \9 X$ p1 m
// Wait until simulation is finished ' K; Q+ E- E0 R. n- ~. G( C
while (!Finished) WScript.Sleep(2000); ! u/ I1 _% ?) ]7 ^/ x2 O* X! h' h
& i, ^" G/ A. g; O5 s$ B" Y4 u2 ?
simple.CloseModel(); ; T' X) r9 J' v- V$ |
simple.Quit(); % Y: c% x( w6 B! W( S9 q
WScript.Quit();
( a3 s' N! u) i" @1 o1 Q) X3 j
4 m- f* x( K* ]! T) S 2 i+ X! Q- X \4 O$ w9 ~
function RemoteControl_SimulationFinished() \& S6 t9 r# z2 n2 ~
{ - ?- H2 E/ Y2 M; T
WScript.Echo("Simulation Finished!"); |