Example of a JScript
V/ t; P `- @var vbOKCancel = 1;
! m: \) }+ i( R) n9 |0 o0 Q2 r" yvar vbCancel = 2;
) t! Z7 p5 `$ p4 C% Cvar vbInformation = 64; 2 O" M6 j8 i6 _# F$ {
var Finished=false;
7 r9 Z/ _( [, s) u $ c6 d, M0 s" y: h9 U
var WSHShell = new ActiveXObject("WScript.Shell");
2 x7 ? u( \1 a! \' [6 _ ) m. g3 V k. c" y1 G/ Q. d9 i
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
7 d! k# w8 k: Z0 Z0 i7 h
& m8 ]. Q* \! Wsimple.SetLicenseType("Runtime"); ' m- G2 r; `! i
5 Q' s; O) q+ r7 b2 Ctry 0 B' y: c. u5 Z) w$ E
{ " S$ P, [: l! Y! {3 {
// Enter the path to a model file!
7 S# F9 |& {7 x2 ]3 Y2 J3 e simple.LoadModel("C:\\Models\\Test.spp");
9 q% H7 L8 z& L+ Q3 ]} . q& ?+ q1 Y- X/ d) x
catch (e)
2 h, E) |& E: [1 ]/ F: T! m{
" E- z8 g p8 X6 I WScript.Echo("Could not load Model!"); + K5 \; C/ p {. F
WScript.Quit(); * S# X, q4 j/ X" j
}
2 M% n: ^3 O1 D0 i/ ]5 J
4 k- g; Z4 ~5 A) I" Ptry
6 {6 n# L1 I' g4 i x: {$ n{ " C; h, e2 @* i; x' q, _; ?
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
8 Z" l6 h* k) @% _" e$ L r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); , y+ s) O& j9 o- _) E
if (r == vbCancel) ' {9 W" e) ]0 Y: \5 b
{ 7 c5 y H. X% c
simple.CloseModel();
% F3 F* u$ A" Q9 _; X WScript.Quit();
! @' k0 l( M( M+ G6 T }
5 N0 c x6 E! D2 \} & i& [+ Z- i K" o, ~9 b
0 Q- m+ x ~; X, ?simple.StartSimulation(".Models.Frame.EventController");
: E% X% ?% [+ E1 x8 v8 P 6 D. @2 |. ?! D Y% J
if (simple.IsSimulationRunning()) V! i! w0 O+ z' U0 S4 H/ z
WScript.Echo("Simulation is running!");
( b j' K" V8 B& x
) j7 N; A" ?# ^( X, U// Wait until simulation is finished ) ^ Q/ @5 Q, B
while (!Finished) WScript.Sleep(2000); - t3 I, D0 d+ V* B2 b
; c; o0 W8 ~" H1 O' E
simple.CloseModel();
4 t: s$ O! ^3 h2 W/ P2 t, msimple.Quit(); 4 Q& `! f. i: l
WScript.Quit(); 9 z; J8 v1 X7 B. S+ X1 d6 h
8 _7 E/ K) A, W1 T! U7 h: q 2 ~: I* a! v+ D; L# t5 _
function RemoteControl_SimulationFinished()
+ `: x3 {# @4 W! \1 w' l5 n2 x{
" M8 r) D& D9 k) @7 H7 S0 A) T WScript.Echo("Simulation Finished!"); |