Example of a JScript
9 G! ^2 {! a; @3 ], {; |3 [: Q4 G" pvar vbOKCancel = 1;
# X1 W1 w% ]! Q8 X4 yvar vbCancel = 2;
4 ~8 E7 d$ ?4 hvar vbInformation = 64;
7 T2 w9 \( l t2 @" x$ G7 v8 tvar Finished=false; . t- h& ] \; }& l. U$ E: `2 Y
7 s8 }2 f# o. B+ y% |' N" ]
var WSHShell = new ActiveXObject("WScript.Shell"); " z K) S+ H% c6 Q' ^
% F# Q( Q% d! U6 ?& V Uvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); - H+ O5 @2 _* y* A; x) R8 T
4 x! @ {' M& C: ?$ J
simple.SetLicenseType("Runtime");
* l8 A/ A; g2 x8 o7 i: R 1 E8 g9 i' i, h0 o$ F
try 4 I; w B( O, G7 F& b1 \
{
3 r' O1 a P! d5 X, s$ X // Enter the path to a model file! , ?6 m4 _- u" b$ t
simple.LoadModel("C:\\Models\\Test.spp"); & r0 @# r1 e/ T' |
}
$ `0 Y6 d* X1 f' ^catch (e) ; |$ r% f$ F Y4 ~8 g& L6 s
{
2 \ B, a9 Z; v7 s* I! C WScript.Echo("Could not load Model!"); $ d- f3 H$ `. V+ C6 B
WScript.Quit(); 2 a# F, y$ i8 O2 `: k! p
} 4 B+ t1 m2 W5 o7 P0 R: q
9 ~; M( c! C* o8 F! V3 w6 `' n9 qtry
5 Z$ z6 c- i0 C{ ' @0 o* q- D3 c3 z
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
; t6 T6 F; p6 B( j% b+ [' u r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); # x3 y* o& x' [" G; n
if (r == vbCancel) 2 l+ v4 ^ s, Z+ W7 m
{ - u$ S% }: L* L" S5 Y
simple.CloseModel(); ' G, a7 R2 b' P8 i& z R. N9 x! ^
WScript.Quit(); 2 l* ^+ C$ [' P' X) w" q
} * P9 K4 c0 c3 z: Y# H3 j1 w
}
0 t! @' R$ i0 a- ^# m 1 r; L, J* b1 U# T- Q
simple.StartSimulation(".Models.Frame.EventController"); 1 K1 ?' v; v9 m- B3 v+ h
) h8 H/ i$ j" k3 Z
if (simple.IsSimulationRunning())
; b7 J# a6 V! s9 I. ?& n6 ? WScript.Echo("Simulation is running!"); : e- |: P1 t, c4 b% W: k
7 P3 m- ^ h/ p4 t V/ n3 A3 B
// Wait until simulation is finished
2 F1 h: P* p- t5 T) B- [while (!Finished) WScript.Sleep(2000);
' h' _. ]% n u , ?' s* \" w1 U3 R- B2 L+ O
simple.CloseModel(); , B# {% ^7 _6 ?
simple.Quit(); / s( e6 T$ ?9 \
WScript.Quit();
9 d8 ^2 t2 d! z$ }7 W 0 U G2 N, [# _6 N
# F" n. i' O1 f% S
function RemoteControl_SimulationFinished() ' \6 I$ j9 @: D/ ?" s3 p! d f
{ * s0 [4 C! F6 \9 \8 x
WScript.Echo("Simulation Finished!"); |