Example of a JScript ( Y. h% k7 }( K7 p& \
var vbOKCancel = 1; + U/ d4 H( e3 z: v
var vbCancel = 2; 9 d- o' t6 b# s
var vbInformation = 64; ( e0 a |" y. Q9 v
var Finished=false; " C8 f" z: e4 E' _" \
6 d( U4 I* p% B2 @var WSHShell = new ActiveXObject("WScript.Shell"); 1 U& @$ d8 A) E8 G* T
1 A5 _- e) \$ @- s. m
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
0 R( `5 i6 g& x" F
4 U/ @* I$ U' |" m6 X% b) hsimple.SetLicenseType("Runtime"); % U# g# C. i, o0 i
3 e5 p. Y& @( u+ h- k# \$ n5 [try 8 w$ R' r' `1 | L7 \1 ^+ y- a) P
{
9 f6 x @ u, m# ^% w0 j7 A n // Enter the path to a model file!
0 ]9 X% O ~6 L8 ] f; I1 S simple.LoadModel("C:\\Models\\Test.spp"); - L. m8 t$ G' b& `
}
; e9 s8 l" k6 ~; Ccatch (e)
3 J- ]! q# U0 J9 _ U* H& l{ % K/ U/ y2 z: S. A) x% W
WScript.Echo("Could not load Model!"); " S# ?0 `9 J, |, k
WScript.Quit(); 8 V* X) u2 B% Q; y3 _
} % [( @6 U' M ^
6 O0 x/ {% g, ?: A7 rtry
( `- b O& j* [. V' R9 Z1 \{ & N& C) |- L' G; U* H( q! }
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 2 b9 V7 `- X" T
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
1 f+ p* Y; {+ I1 m9 D" @" L if (r == vbCancel) * u4 O# ?6 w: [$ L) \
{ . u9 q/ i# K2 r" Y' \$ d
simple.CloseModel(); + p3 x8 S6 L' z8 |
WScript.Quit();
1 Y% ?) R8 v* L5 [' N. T } , K, o/ w' D$ K, f+ e: Z
} 0 B6 ^+ J& o6 \* {
O% ^: O' K6 E# q, E
simple.StartSimulation(".Models.Frame.EventController"); % S A) q) u* G$ }2 ]
1 D" f) s* Y2 d% d3 ^ T3 s! V
if (simple.IsSimulationRunning()) 5 q1 \6 u% I9 x8 t1 C0 D; J
WScript.Echo("Simulation is running!"); ' T. F: Z- `0 A7 M+ E: n
# Z( u8 J, [- y7 o
// Wait until simulation is finished
% h! \* o/ A5 S4 O- b2 g6 Nwhile (!Finished) WScript.Sleep(2000);
3 K$ s0 S" j: o) B- L- _
% N# [ x7 R8 E% m; wsimple.CloseModel(); ' E& N$ @! X' {+ @, _6 q
simple.Quit();
, h, K' s" [( S X* t" g0 sWScript.Quit(); 0 s, m. ^+ S% t8 j0 I
# X$ S0 [2 r+ g+ v+ o9 Z / e2 C" O3 t; J
function RemoteControl_SimulationFinished() - W! x. g% s2 F# q" \
{
3 z( v$ E# V' v7 n, z WScript.Echo("Simulation Finished!"); |