Example of a JScript 6 p* V) I I4 R1 S
var vbOKCancel = 1; / U3 F& `9 f. D5 K
var vbCancel = 2;
; L" D9 H1 U* F W6 D) Rvar vbInformation = 64; * U- v6 a: d! D0 ?
var Finished=false;
0 O4 h) {/ ~+ r1 W" c, A B
; D. ~, P5 M+ `: x# evar WSHShell = new ActiveXObject("WScript.Shell");
# u# r) F0 f5 q0 ~7 x
2 A+ G; ?& r+ R+ s9 R! M& F. svar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 4 S0 |* t v6 |7 r0 b" J0 V) J7 o
$ j( ~, p* S& y+ ?
simple.SetLicenseType("Runtime"); 9 O9 R& Q6 [3 [& V+ A
8 Y# {. m4 _4 Q! q3 @& i
try
) w% |9 u1 P# ]( J6 y( f2 r! K6 Y{ ]6 t' H( m) p! [) O( R
// Enter the path to a model file!
. P; X' A/ \& x8 E* ~7 z simple.LoadModel("C:\\Models\\Test.spp"); 5 j$ A/ ^+ _4 [) H- }# r9 @
}
/ o7 g- a2 D# a) O' K7 Rcatch (e) 6 w% _3 P" ~ R$ m& [" o; w$ h7 q
{ 2 C" P4 A/ x, I y/ n
WScript.Echo("Could not load Model!");
5 i; c0 q# R8 q WScript.Quit();
) C" {+ k7 O& _1 S} 3 R& M* a" \2 M" l3 f4 g, r
) z4 e& P2 m3 G. R- Q
try
8 ^; K# b0 m' Q! |- X{
* _' X, |9 {8 k1 [/ ~: O simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { - x# m' H8 N! R0 l/ x
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
+ t! w( H# O1 ], R' T s) _# i if (r == vbCancel)
1 h7 l9 w: ?4 @# Q* F3 Y* T- A {
% _0 `. ~8 s2 L [! v. O) Z: M simple.CloseModel();
: r/ f3 F" S0 J4 S WScript.Quit();
, Z8 K) K) V8 _: G" t, f } + z1 A, b" a. Q
}
0 V# b0 b( E( T' }! z/ O " Z6 l* y6 {. [
simple.StartSimulation(".Models.Frame.EventController"); 7 D) c6 _ A) k+ p0 B% A
) f+ g1 W" y8 L: ^if (simple.IsSimulationRunning()) 8 ` f2 F$ C- F
WScript.Echo("Simulation is running!"); 5 }+ ~( e: C9 |2 l9 Z; x
: v) b d- {& A% w// Wait until simulation is finished 7 e; g/ h: ?% D8 f2 K0 O* ] b
while (!Finished) WScript.Sleep(2000);
2 H( J+ w& F }1 V. u + V- _0 d2 t; y2 r5 G7 I
simple.CloseModel();
& V) z6 g0 ]0 p( O& isimple.Quit();
0 v/ D! S" e+ G( s6 ]0 b2 Q' sWScript.Quit();
7 y6 k$ U) R, X+ _" C' G0 ~ 7 J* y% C1 K! M( k% b0 b
% u) m* |2 D$ X+ i/ r
function RemoteControl_SimulationFinished()
7 u b9 y0 |3 J- e; F# A{
/ {+ |7 ?7 o& s9 n3 k WScript.Echo("Simulation Finished!"); |