Example of a JScript
7 D' |; x, l+ @2 P# e% }1 @var vbOKCancel = 1;
# `6 w! S# v0 Tvar vbCancel = 2;
3 |$ h/ j9 f. q# wvar vbInformation = 64; b9 m, `% T" n z s
var Finished=false;
7 u0 M. Y! e' l$ i7 F: _2 d7 H# I3 O
# v7 V: D" `- h4 g+ U1 X' n- L& @5 Hvar WSHShell = new ActiveXObject("WScript.Shell");
' w2 M1 [: v8 y
* H3 `2 J! ~) s% R% F1 s) wvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 0 V _9 c" w6 y9 O$ x
+ J( a$ y; W `+ C
simple.SetLicenseType("Runtime");
) S* e; f5 j) O6 l! H5 w" c) ~
, s7 O& ?) R/ X! a7 @% n# Itry 6 c8 s& ]1 u/ u" R8 @4 T4 j
{
8 S: d) {6 ? r9 H9 I9 p$ N // Enter the path to a model file!
8 `1 e- q$ \. Q% A; X simple.LoadModel("C:\\Models\\Test.spp"); ' d0 i J& D( j) [6 ?- T$ w) s
}
6 f" ~0 ^! s5 e+ _catch (e)
# a$ V! x4 W, b+ f2 |{ ( V/ ]" a3 _% z+ h# a) g& J
WScript.Echo("Could not load Model!"); ; n* w; O" a* _+ A% J0 ^
WScript.Quit();
2 V, Q l6 l8 s& s3 u}
6 I2 n& T# i2 `0 L: z' G0 q3 K 0 @# e9 |# [6 M" b$ u+ `) u# ?2 F
try ; F% Z. I3 @; v1 n |
{ * M; k7 {( b m
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
# X& I4 o" k* C3 o* w r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
" V0 U, s6 l$ }% c( ~ if (r == vbCancel) 4 }# G+ J/ \* [0 H; S4 S
{ 5 A! Z7 y6 r- O5 i5 n( E: R
simple.CloseModel(); . [: p5 C! r \6 j. B! J
WScript.Quit();
7 B8 C. n+ \- L3 f } ! H5 W0 Y3 i1 A9 [% V
}
7 F5 }; p5 Z2 G- e" @) J
' w9 J- {" K# w% Vsimple.StartSimulation(".Models.Frame.EventController"); 9 w- T2 J# `5 q& W
. Q" Q; m" ?; w8 r- X4 v
if (simple.IsSimulationRunning())
. L. `( Q. _3 f% a" |- ] WScript.Echo("Simulation is running!");
8 R' H5 h/ v) m: E9 u7 b% [5 } 4 T9 y$ f4 I& q& \, z8 J
// Wait until simulation is finished * v& |/ C' D' d
while (!Finished) WScript.Sleep(2000);
( z% L7 G& z; q [/ W3 u
! ?* f. g/ ~# `6 T4 p3 l0 jsimple.CloseModel();
* P- n. R R n% `simple.Quit(); : m# H* x; \ Y
WScript.Quit();
9 t$ S6 F; m5 g6 D: L# p
: `2 F. K4 E. O+ L. j+ r2 b0 T 9 g; s! M2 R$ Z5 F
function RemoteControl_SimulationFinished() ; E6 P+ Y7 \& o% K
{
" A% @& G* l6 F WScript.Echo("Simulation Finished!"); |