Example of a JScript # W6 G& A7 {& f* z+ A4 I* Z
var vbOKCancel = 1; ) K, D4 d3 E" n) ?; P* v
var vbCancel = 2;
5 P# w8 F7 j6 }0 k2 M* B# o# @) nvar vbInformation = 64;
" n& m$ F" `* f) Evar Finished=false; 5 n& k6 L' v/ x! L, \
G& ]/ w' c/ }' j% _
var WSHShell = new ActiveXObject("WScript.Shell"); ' r' D: {2 l4 f! p, H5 {
5 g9 m& F) N5 E6 v# J3 ~& B' x
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 4 W" o/ E1 |8 M4 ^5 e! T% N
& r9 i) M8 @5 X5 b" {1 Hsimple.SetLicenseType("Runtime"); - u6 a, Q. P3 A8 @4 t7 W
p9 `# L! n7 g
try # Z1 a6 W. M8 o4 o" O
{ ! g, A* w ]% [- t1 t3 h, s
// Enter the path to a model file!
9 W# k$ p+ ]6 s: Q' n6 e) u simple.LoadModel("C:\\Models\\Test.spp"); 8 T) v' r6 [. l/ x& n6 H4 ^2 O" Z/ |
} b. v% r, u! P/ }
catch (e) ( |$ C) F% a! \& j5 q9 v- `
{ 2 S5 j5 T' f: m
WScript.Echo("Could not load Model!");
5 a+ f" u) ]( u( ~2 `4 n! R WScript.Quit(); - j7 N% r$ A) o2 T0 a# I7 d
} - u0 f* F9 U0 O! C& ~. m* t
+ G1 g( h/ _' ^; Xtry
/ ~0 l' k2 G' K' K1 `{ # @8 R3 J2 T% ~$ m1 C
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
; j; x K1 G" n" M r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
& {" i) g" N. F9 G5 O3 c5 x# C if (r == vbCancel) 2 Q) {3 b. g. }. Z" E( z# L; v6 t* D: s
{ ! J7 {& _* y6 N2 N) G( ^
simple.CloseModel();
* ~' M# b8 W2 m6 y WScript.Quit();
3 x: H0 J: r# D7 Z" B9 G ] } 0 G! g. r9 t% M+ m5 o
} 1 |; V9 {% j9 r6 W! J' d0 z
) J( n: }' f" _5 p/ a
simple.StartSimulation(".Models.Frame.EventController"); 3 n2 ~. R" G6 P* B( d/ ]
& f' `3 G( y5 o: q2 ~if (simple.IsSimulationRunning()) , s w, _) `$ A! a" w( f
WScript.Echo("Simulation is running!");
* n5 y L) W& U, x 2 B5 X- R/ H+ f6 h0 K
// Wait until simulation is finished
, }0 b! l. o+ xwhile (!Finished) WScript.Sleep(2000); : _. e- o$ v5 V$ m
4 V9 _8 ~) J/ Z
simple.CloseModel(); $ s- e0 @0 q* E& d- ~+ K! |
simple.Quit(); : J! b: h0 W5 j- S H
WScript.Quit();
4 d' i; X$ I' p% \
6 d8 c% c1 Y% H* h- Q 7 v# E3 H8 l( u" G3 ^
function RemoteControl_SimulationFinished()
k7 j( D6 c3 G0 h/ t9 e{ % K& ]' ^; [6 r3 M
WScript.Echo("Simulation Finished!"); |