Example of a JScript 9 D) v9 p7 u/ u# R
var vbOKCancel = 1; # c2 n. V) q2 g% d1 o, K# U
var vbCancel = 2; # y z! S5 f; b5 w% O; y# G
var vbInformation = 64;
) [" k. {: T2 @% I! A& F, `var Finished=false; 0 z. V% z6 ~9 Y
3 F8 k' |- ~* [
var WSHShell = new ActiveXObject("WScript.Shell"); * {6 |% Q; y( q
6 a5 q& H8 A, \, d. Y" gvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
; j, X4 c8 w$ U9 q ) i# k# t6 a+ F- S) y
simple.SetLicenseType("Runtime"); $ i: m3 N* x2 i: L( @; E+ D
) F3 Q/ i* {9 p! o& _( ctry % h' ~% _/ l- U5 ~5 O- v2 v
{ 5 H( D$ } y5 v, B N
// Enter the path to a model file!
3 B$ x4 d3 `2 K6 R simple.LoadModel("C:\\Models\\Test.spp"); I: t6 c- m" o, Q* B
} ' V5 \7 e9 s5 T3 ~+ q7 M
catch (e)
! m1 t* w4 N0 T, J9 |# H8 }{
0 ^& b' f6 E1 m* ?5 O5 W2 {5 d WScript.Echo("Could not load Model!");
' ^/ X8 J( @* X* ~& a WScript.Quit();
$ t! C0 q" I! |4 H- h9 c( Z* J} 3 J, {1 X2 S) v/ W
, B4 O" V. B4 e. h) O8 D7 a
try
3 v! f1 u4 V- U- w{ s/ D( _$ o* I, [9 W& b
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 2 v* ~/ a g0 x* W5 E5 i# k
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
6 p# N: k4 i& l& r6 T- P if (r == vbCancel)
8 H; b; W, i ^+ Q0 I" i6 _ {
1 B, p/ e" D; }* P$ `+ s simple.CloseModel(); 7 L2 ~- h; L- [* ^& u. n
WScript.Quit(); ' k- c7 T# S3 [; |* w" W2 ]
}
- z8 N: g, R7 e# t. l; ^+ }* r}
: G! r" W E9 w4 c
) y# V' Z- d0 ~2 A- Z2 Y' usimple.StartSimulation(".Models.Frame.EventController"); * w$ P) j5 D) n2 l
& ?- ^! K) a2 { W- p
if (simple.IsSimulationRunning())
% ?+ T4 c2 f- a. ?! T7 z* R WScript.Echo("Simulation is running!"); , l U0 R0 w0 S' ]/ f6 ~
. {# d, P H! h, p% b( ]
// Wait until simulation is finished
3 s# R9 Y% [7 M1 B+ j$ ~; owhile (!Finished) WScript.Sleep(2000);
# E% d7 l1 u7 L; F 3 e! K. K8 D" f. R1 t
simple.CloseModel();
+ B- D$ w; e7 |8 E6 xsimple.Quit(); ( }% [7 F5 S1 R, q4 l$ S
WScript.Quit(); * D2 [9 U2 l) J8 K( |
: U+ h% j4 \! U6 F4 a 6 [0 k6 G+ y% r8 i3 y
function RemoteControl_SimulationFinished() 4 O& p/ u/ I; @4 f# \
{ 6 @1 n0 Y* G1 W# n0 m1 ^& B
WScript.Echo("Simulation Finished!"); |