Example of a JScript $ F) T6 _6 I0 c5 c2 I
var vbOKCancel = 1;
! X' ]# y; `2 E0 T$ f: p) zvar vbCancel = 2; 5 t2 E8 g" O1 p8 t
var vbInformation = 64; + }: t8 R% v, G/ b* S
var Finished=false; , n) w$ L% `4 \$ F- s
4 q* `4 r$ D' y3 D8 s' u; yvar WSHShell = new ActiveXObject("WScript.Shell");
* V4 P8 k+ i3 n- C3 `' f: e) H0 K * |% f p# U: d( @; q
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 9 P6 h: _: Y1 K5 A
+ q0 k! g! X' {" v. |: V$ ksimple.SetLicenseType("Runtime"); 9 }' l) H; X$ d x" `, j0 |
* s' _% w( ]& [- ctry
( m1 r: r! r# y: U7 @{ 2 K1 O3 u+ J$ O- K& E; X7 _
// Enter the path to a model file! % }" _+ y% f5 Z. }+ X8 U
simple.LoadModel("C:\\Models\\Test.spp"); : Y* d ?8 e5 O% U7 m) R
} @4 {3 ~* p. F( k
catch (e)
$ g6 G w* F# I% ]; e{ 3 \1 G" H: N2 }: G
WScript.Echo("Could not load Model!"); " n4 _7 _- h# |( U
WScript.Quit(); 5 j( u; O8 S+ e! ~
} + y: K8 k7 U/ g6 f# L6 E
3 U& d" V5 B9 O; a( @try 9 v1 ^( A" z6 F4 Q* Y9 h
{
% ~6 f5 D1 z; X! E' Z7 T l4 E3 Y simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
* p1 i m7 x; X. D3 y# F, `/ w7 v r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 3 d5 k+ Q/ n5 k5 w9 M
if (r == vbCancel) $ s! `% J. n5 o; j+ M i
{
; t9 Q; b- B9 J5 _( s simple.CloseModel(); & n& X3 l) g w/ l3 o! @
WScript.Quit();
: a* Q o2 e2 o }
& F% @7 X3 M! ~} : D; F4 p+ D# J2 P4 b" f
: X3 }3 j8 U' K! b( T' F1 m% V
simple.StartSimulation(".Models.Frame.EventController"); 5 t0 Q' L3 ]0 v
2 y# M! H b: d4 ~+ V) j- ~- H! w
if (simple.IsSimulationRunning()) % t. K6 ^$ e% }, \8 f' _3 }5 L
WScript.Echo("Simulation is running!");
8 y. K1 l# _% r2 Z6 F0 F& Z& i
F( m$ t# E* f7 n) H& r+ J! P4 N// Wait until simulation is finished
+ q' d% b. H: v. Gwhile (!Finished) WScript.Sleep(2000);
, ~/ L9 m( u. e% B$ | 8 |: m# J4 i1 z" n1 j6 v6 v
simple.CloseModel();
. B# y: @0 A# T6 {simple.Quit();
+ V5 T8 m% c# z4 v _1 }WScript.Quit();
/ k0 U0 a5 T! E9 c6 b) Z, A ) V+ O+ |% Z% K$ C
1 I6 d$ s7 U% R: q8 }) Tfunction RemoteControl_SimulationFinished() 9 j8 _# v, B: V& x
{
$ y' q1 N8 o0 r: p WScript.Echo("Simulation Finished!"); |