Example of a JScript $ M# _$ B: h! C5 O9 |- Z$ Y$ g
var vbOKCancel = 1;
) R. J( p$ J& x6 d" S0 {4 pvar vbCancel = 2; # D% A8 S$ b. Y2 k0 t
var vbInformation = 64;
6 Q+ |( P* q3 W# q' w: kvar Finished=false; 0 D5 j2 c/ w% M7 X3 m8 g2 w
4 U& R- z6 N" k( v7 G: S4 @9 H9 f
var WSHShell = new ActiveXObject("WScript.Shell"); 0 A# S! {/ B! u! e0 d1 O& }
& r+ g( P( _7 I* a
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
- O4 D& Q% g e, m6 P7 o & {, e9 R, b3 L- s9 Z& B8 C3 }3 F- I
simple.SetLicenseType("Runtime");
* f6 D. G- `. P. V6 i3 T! w& O0 n ! T3 N: s7 D, a. Y0 t7 {
try
- f! ?4 X. }" E& M8 Z1 R{ ' `$ S5 v+ n9 L V
// Enter the path to a model file! 8 S( |: N/ T4 e2 }! K5 t
simple.LoadModel("C:\\Models\\Test.spp"); 8 a( M+ g5 i" U% v
}
" j5 Q w; B! O8 U2 J9 Kcatch (e) ) h8 I: n9 P. x! v7 ?. I% c
{ 6 g0 j u' I9 j6 e1 |$ ^: s
WScript.Echo("Could not load Model!");
) @- d* D# ]( b/ A+ m WScript.Quit();
, R: o5 H1 G1 i} ) G8 l% n& l ~" L+ T
& M+ w. {; Y5 [ C \try # J5 O# |/ y; R! a! S
{ 6 D W0 g8 K6 f) O
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
/ |& P, i' V: M8 g r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 9 Q/ Q& s; V% F$ Y/ I" M
if (r == vbCancel)
* [! f) l1 Y6 T3 e/ k {
5 w' \: B* P* \1 J simple.CloseModel(); : I$ l" W, B2 D0 l9 C6 Y
WScript.Quit(); + k+ b" t8 L8 D9 v1 y
}
3 D) P6 ?, m; [& P2 H; _}
% G& V q M& D9 K) H
, O7 }7 \( [1 @+ q& J& Gsimple.StartSimulation(".Models.Frame.EventController");
! b& d( A# n3 D! }$ M, U* B
1 _9 O, w6 N! t# J% T1 N lif (simple.IsSimulationRunning())
& c% b+ I3 H, B3 t0 B$ r WScript.Echo("Simulation is running!");
1 `( y w7 Q. }7 i
* w( ^$ x/ s2 z// Wait until simulation is finished
# A8 p& z! v& |2 l6 B C% d% ewhile (!Finished) WScript.Sleep(2000);
# k# | J9 u$ i ) I- w( v6 F/ E$ B# d8 v& t# u
simple.CloseModel(); 1 a1 D/ ^, m- O0 l2 _: t
simple.Quit(); 8 z0 [& I" t7 X. U. x3 k: Z; z
WScript.Quit(); ; @. n2 H% k; {5 x9 U: @! H' ?% |
) R& W) |5 q% g" A
* K$ |/ |+ T) I# r4 i( g4 @5 pfunction RemoteControl_SimulationFinished() ; l# l; e5 E' r- C5 |/ ^
{
+ F5 z! e% W/ k WScript.Echo("Simulation Finished!"); |