Example of a JScript 7 c% E* i# q @; I6 l8 S% V
var vbOKCancel = 1;
0 ~8 `- Z2 q, s) B% vvar vbCancel = 2; 4 d# u0 Q& U7 D" L6 V3 J% F% N
var vbInformation = 64; 5 J# n% A! _# \
var Finished=false; ( F3 i. ^) Y1 ?
$ k' G5 U$ z. X# tvar WSHShell = new ActiveXObject("WScript.Shell"); 9 r- r4 W- T' O
B% I- G6 ^4 m$ { t$ ]var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
3 G0 N' T p$ _2 x- \4 g1 P
B5 ?" y& Q6 m4 J& `4 s6 wsimple.SetLicenseType("Runtime"); 5 s: d& [& R5 ^" j0 v! h' z
0 b4 A# L$ m y( t+ @ i! E5 w$ otry ) ~: F% H3 w; i" N
{ % d" x5 D; q4 d9 P& _0 A6 _3 l
// Enter the path to a model file! 3 P) v8 E- d. K
simple.LoadModel("C:\\Models\\Test.spp"); 4 T9 R7 B0 _; N3 T
} & t I; j. ]8 ~( x. ~) ~4 u& m
catch (e) , j8 `5 Z4 d, f. y7 C
{ 9 P5 B) j) t. c* V k1 k# ?
WScript.Echo("Could not load Model!"); 4 p& d6 G" ?4 [0 L
WScript.Quit(); $ z0 d) I2 Q+ d- Z9 y! r( P+ x7 i
}
- h6 p' G/ W& r, B& q# ]
7 q0 y+ Y$ P3 t, p& n% G K5 x5 Ptry
9 H* } h9 h7 K) ]; T# s5 _% }{ 1 s8 n5 `' o/ n* q: T9 M
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
3 u0 h* A! H, t; A5 a r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
3 }2 \6 k: m- N& G( u# p2 U if (r == vbCancel) ; f9 z6 d/ y$ p( P5 R6 u% K
{
5 K( i% C) {; k2 R B simple.CloseModel(); 5 N" ]' `5 B; y( y# D0 v8 I' U
WScript.Quit(); ( W+ J! s! o/ {; r
} # P v! [" R. p$ B: Y- ?
} + X# J0 w y" K5 A! U
" ~# p& @6 }' E2 f _, Gsimple.StartSimulation(".Models.Frame.EventController"); 1 B3 q+ Y( p3 G; s0 P$ M1 z
, G, _) J5 J. G" p8 ]: Rif (simple.IsSimulationRunning()) 7 i0 D: [, b2 z6 s! `% u
WScript.Echo("Simulation is running!");
+ g# W8 x2 p% V: l7 r2 M" F
% U2 h/ ]+ ?0 k: ?+ O" B// Wait until simulation is finished
( K: l7 h0 |0 `' _& G2 Lwhile (!Finished) WScript.Sleep(2000); ; C( ~9 a: v8 g" a2 H: ~
% X! a: }% E8 b: _1 Y7 g
simple.CloseModel(); + N& M# J/ A5 ?) Y0 O& F% H
simple.Quit();
& l0 v' \7 K: b: y4 N4 O o! [) rWScript.Quit();
8 h) r6 `. ^2 o7 B6 C4 O
! ]( ~: o2 v; r I. T4 ? ) p9 V( h# F) p1 h" [
function RemoteControl_SimulationFinished()
/ p; A% ?& ~/ c{ . i2 [) _; g1 z V4 u4 v
WScript.Echo("Simulation Finished!"); |