Example of a JScript & x7 X! p1 v! x' A ~ h1 _7 i
var vbOKCancel = 1; / O3 @! s0 Z. s2 e
var vbCancel = 2;
5 s7 \% G: V7 w! q. p) W, A" Cvar vbInformation = 64;
# C) J9 M; W8 v% fvar Finished=false;
0 Y+ J6 V' r( {6 ~( I
- B* I( d6 ]0 |1 y0 yvar WSHShell = new ActiveXObject("WScript.Shell"); 5 F% L8 s5 B' g: Z7 d3 t9 E" m
. A. U% z; i) Yvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
1 c* S% X* w* ~$ n5 N; j9 d- o& T # R' X0 `# j/ e8 J% C
simple.SetLicenseType("Runtime");
& Q& `/ W( K( d- {2 d 3 s! i8 V: A }: y. P+ |/ C
try / k/ ~1 H( \+ t( c+ k
{ 5 G- ?: |2 K" R0 q& j2 ]0 U
// Enter the path to a model file!
0 x% C! ?* S1 H4 X simple.LoadModel("C:\\Models\\Test.spp");
8 W: f' H5 \& \! w9 q/ J! D: s}
5 T, R8 Y; l B1 B+ ncatch (e) ' U1 r) f* D) j) s; Q( q3 R: k7 U
{ 8 D7 E: |1 C. U
WScript.Echo("Could not load Model!"); : _, B8 c* R- f: {
WScript.Quit();
7 j% D: M6 M" @% O4 \" E} 2 t; _& [5 p) |
9 j6 |4 ] x% a8 q8 H* Mtry 6 Z' i/ Z( m' R( l0 x* G
{ m2 B7 k* y# L' \5 a- K8 s6 r
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
2 Q( E9 ^4 p/ B% O r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); : t7 O) ?; L3 K3 j! \. ~
if (r == vbCancel) % ` _4 v0 y& Z( B+ B7 j
{ ' u1 j2 e# A/ _7 Y9 d: n7 c% z
simple.CloseModel();
8 ]( f* R. W: J/ ], \& _& @# F1 P" a WScript.Quit();
. M& {. w7 @6 W" D" w0 a6 S) { }
6 M+ q4 B+ h- k}
# W( K- q9 L, o6 y3 O ?2 A# g 6 A5 `% x/ \6 u( W
simple.StartSimulation(".Models.Frame.EventController");
4 o# h* U* ]% w) C+ [( B, j d
, t4 k8 x, o |( H0 h1 Iif (simple.IsSimulationRunning())
9 u) x' _5 r+ ] S6 @! ?1 c WScript.Echo("Simulation is running!");
4 r/ f% Z7 g* [! X 9 s M! `) J5 D2 N
// Wait until simulation is finished
. i5 B$ d" Y4 r5 y9 R% t6 Qwhile (!Finished) WScript.Sleep(2000); . N+ J7 W, v$ ]! P( q- z7 v
8 C% U; B5 ]# ^0 P. \- Z" Y, r4 h
simple.CloseModel();
3 }! H* F; |/ a. w6 w( nsimple.Quit();
" W z1 |/ a6 j/ n [0 ~WScript.Quit(); - c2 j* Z% j3 C- o8 d
4 z0 n0 W& @ d( n5 \( j* _( f
! w- D v7 \- u
function RemoteControl_SimulationFinished() 4 q3 s5 H9 w* K, }3 {8 _, @. X) F7 t
{ 3 y2 e j# |6 Y5 y1 P
WScript.Echo("Simulation Finished!"); |