Example of a JScript 8 j+ ?5 o+ k1 n8 E1 E' X& V
var vbOKCancel = 1; ' |8 f3 M/ }& [% B" z
var vbCancel = 2; / _, m: ]) j0 Q3 {6 g7 U0 g1 C, U) B4 K
var vbInformation = 64; 8 D6 {! O3 H6 J4 W% ^4 `. S
var Finished=false; 6 k2 W- p3 \8 j( x b. F
9 B. ?! G+ T7 I% h' a7 u& z1 q3 h0 F
var WSHShell = new ActiveXObject("WScript.Shell");
5 M* `$ k& H/ y6 M2 r+ V ) m2 Z [( m0 X* l+ V) ~" _# N
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 9 g2 C1 Z3 _% c; R( J
8 S& r" e# h& l% n8 V/ t4 ~6 }( w0 P
simple.SetLicenseType("Runtime");
, T. B7 r1 I7 ]( e+ u
: Z0 J' v' O8 F2 o- Ctry . N% G$ v/ s& ^% ~. g0 s( M
{
h( X7 u* J# B) m2 R // Enter the path to a model file! ( o% i; ]' n8 T. v" \! b. r- i
simple.LoadModel("C:\\Models\\Test.spp");
1 F8 E: N0 a/ C( s: {% r: B} , U' c- g6 z% D. K! X7 n0 u
catch (e) - @9 q7 \' n; N$ I
{
& n) O# X. c7 `9 U6 S; W/ F% u+ T! P WScript.Echo("Could not load Model!"); 1 K8 h+ W+ c3 \% `: P3 }" B$ h2 E
WScript.Quit(); ! _& V' D5 C+ g ^$ F
} 8 V! g0 ?5 a* v9 e1 k5 i& a$ L, v
7 B6 A4 i' c1 A9 t: G2 P Ktry
7 r5 |% P' q$ @3 |{ $ H# s$ o$ a! V" r
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ' i# f8 d+ f; B0 h
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
0 X$ ]" R0 s1 K) j if (r == vbCancel) 0 s' g+ f1 a( E; u* V$ V4 Z6 o
{
$ f% w- x7 w+ {) V8 _* `8 a2 p8 ?7 ]: j simple.CloseModel(); . y0 G. }+ `3 R7 L+ ?2 s4 q Q+ B
WScript.Quit();
1 c( J; x: f1 |9 y4 } }
$ T ~# W/ A2 b% R} * L- G& T5 X: i
2 p& h9 @. H: v7 C# \
simple.StartSimulation(".Models.Frame.EventController");
5 l& G! S" t- {' s % k6 q( }9 y ^9 X: h+ _" P) t
if (simple.IsSimulationRunning())
' E8 Z5 n' o' j& E+ w* ]0 M WScript.Echo("Simulation is running!"); 7 D% M l+ E6 V, q& `4 D: S3 e! A
/ Z% C f8 b ]// Wait until simulation is finished g: n) H# J. h! X: B, p' |( I* X
while (!Finished) WScript.Sleep(2000);
6 H3 |) p5 x0 [' _; h7 Q5 X+ K
, P* T2 s! S! _: Bsimple.CloseModel(); 0 p8 n& C( O* r
simple.Quit();
1 _+ z$ W D& y6 H8 x5 @WScript.Quit(); 7 [8 P0 G. R9 k$ A4 w
% a. D( [( e2 _* [: P$ I- I2 d
4 L& I* E, O w. a: k5 y9 [7 ?function RemoteControl_SimulationFinished() - Y5 l$ s4 Z, d: X% a, G
{
' |3 e# |& H4 I! s WScript.Echo("Simulation Finished!"); |