Example of a JScript 9 F* \4 Z$ g6 R7 O
var vbOKCancel = 1; , }1 c/ d: N! ]. C
var vbCancel = 2; 7 _$ X1 _5 D. o8 g, p% w
var vbInformation = 64;
% g) o6 |2 M) zvar Finished=false;
$ a7 }8 m, u1 B, u/ C% ^! @# { ( F5 Y: l6 p( a+ e$ y; A( a; Z8 h
var WSHShell = new ActiveXObject("WScript.Shell");
+ M) P ?+ z8 M
2 N" H5 P* z- H+ P! l* b$ c* R9 H& vvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
n1 U+ I) e) m! @. I, \ + z- C8 E' T& V# \( ?. N
simple.SetLicenseType("Runtime"); 4 {( t4 L3 w3 O' y5 b
: a+ @; c" y& w, ctry - ^* A+ h& o) q. E
{ ! n; j0 L3 ~' y; C2 D( a; ~
// Enter the path to a model file! * v! l2 s! ?) {5 G( Y7 r
simple.LoadModel("C:\\Models\\Test.spp");
, o t: c) {1 o5 \1 G3 b s) L}
. O0 l7 o+ }5 P n0 k9 H" xcatch (e) ' P, ~1 o3 t8 G
{ ; @8 c4 l/ W+ O# h
WScript.Echo("Could not load Model!"); 8 F# ?* V: g1 S, S
WScript.Quit(); 0 ~& O% g/ p" J+ S9 T9 I3 b8 d+ I" K
} * A/ j) y6 j! t0 o {' B, r
. t1 }$ T' l; n# I- r& L
try
' m) A2 U* O) L8 I) Z5 W( q. ~{
+ L$ @* z& w6 R1 |2 [; w simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { * M; B+ _. E+ q
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); / G# ^: V6 \* L* A5 Q* z( E6 _5 q
if (r == vbCancel)
+ h1 ~2 J, P: Q& Z { ( K2 ?" Q' V4 L0 A4 J
simple.CloseModel(); - U/ S! c6 d3 d+ f2 D1 q) I6 _
WScript.Quit(); : g% \. f/ A7 r# z( W0 g2 Q
} " R9 R& i0 g: t, L# p, w+ _
} 8 b `( }6 E2 q. U
0 U+ ~. t7 ~4 p# R7 g, }
simple.StartSimulation(".Models.Frame.EventController");
: j2 G o1 k& K- U" n
! Z4 Y0 P) E7 r lif (simple.IsSimulationRunning()) ( d1 K" E+ @! C; }& R9 O
WScript.Echo("Simulation is running!"); - @& f( \% F! Y8 j" K' C
7 R+ J; L0 @& N
// Wait until simulation is finished
3 ?/ }3 P; a2 ^" g4 hwhile (!Finished) WScript.Sleep(2000);
* |8 ^! J$ b' t! @* O
- ~8 O p0 i; R0 g) T Isimple.CloseModel(); 2 S# H- y. A7 B$ D4 }& v
simple.Quit(); ! X% S6 L0 I6 e& c. V
WScript.Quit(); 7 s4 k* {$ a* D! ~) G# o; {
/ k% n/ g1 ~ t
6 Q G. S* w! `3 i+ L8 s
function RemoteControl_SimulationFinished() ! P( }+ d( ^( ~2 a$ Q3 \7 u- f( X+ P
{ " Y4 r+ J' P, `) y! f
WScript.Echo("Simulation Finished!"); |