Example of a JScript 3 ~0 }2 E! F1 j5 K- h, V" q
var vbOKCancel = 1; * V6 l1 L' q0 W+ v$ U3 I7 K" D
var vbCancel = 2; 7 I: S$ {, ]- s8 G
var vbInformation = 64;
3 J2 `6 i# _. O/ m* Hvar Finished=false; ) M5 X& a' Z$ l6 g+ C" _; y
1 e& \$ ]8 A u q
var WSHShell = new ActiveXObject("WScript.Shell");
1 v# j0 h. n' {- x" q; @4 R , M# {' X1 f+ L5 J" H0 o+ I
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 7 I: y* `+ _. d
+ X2 c! G! _; W Y2 r8 p1 Q V
simple.SetLicenseType("Runtime"); : V, Z) k+ F8 E0 ~" d9 Q/ Q+ U
/ r# t5 H6 L! p! ]3 x4 wtry / S8 ^5 }8 v- x0 K% O2 v" ]
{
9 w' {$ R7 o6 N) y! V: u // Enter the path to a model file!
; X9 V5 C" k6 L* C: ? simple.LoadModel("C:\\Models\\Test.spp"); 0 m) h+ ~/ {" r* c# D
} u) |: G, L# o& U \
catch (e) , C, Z/ h+ a# z6 g/ T0 p5 v5 S
{ " P5 Q5 Q$ s3 l6 \. H5 \5 h
WScript.Echo("Could not load Model!"); 3 B+ ?: Y, N( W
WScript.Quit();
( D& i9 m: b1 ?& | P' u. y+ l}
, }( B# i+ S! t; t; } O* i+ K1 P& p9 r9 f( e" d6 ^* W
try ; N/ h1 a& x# k
{
# g6 j; e* d h4 h& L0 u6 C+ { simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { + S- j6 ~% M# |8 e( Z
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); % A6 L2 I: \, U; T$ O# q4 `
if (r == vbCancel) ! x5 _; P1 u+ P2 p, j6 Y8 q N: Y
{
; k( | N4 X8 G simple.CloseModel();
+ W) x2 K' J. O6 M! v7 v" L0 n WScript.Quit();
0 v& }; A- b G, C/ o' q } 8 b2 N4 \- |" c
}
& v; i0 q3 H7 x% w) R i+ i
5 W% f% h( t! i" C. ysimple.StartSimulation(".Models.Frame.EventController"); 3 [) D9 V, Q5 t' k: O
3 _6 ^$ S, V. ?5 i7 t% r, hif (simple.IsSimulationRunning()) ; `# ^, L$ u2 r$ h- D0 U
WScript.Echo("Simulation is running!");
' d( t9 P+ Q$ i! M$ x) k1 t8 a
- V, I! |, w0 {# l- }/ g// Wait until simulation is finished
) M Q( u$ S' ]! B% J3 Qwhile (!Finished) WScript.Sleep(2000); 1 t: {# ]7 Z) t. w- s6 t$ n4 P
9 N+ `6 I7 x8 q( Nsimple.CloseModel(); $ G9 [ [4 q8 T6 k1 T/ |8 G: L
simple.Quit();
" U4 S: b' `* u3 h: a9 HWScript.Quit(); ; o$ z5 t9 @& }: y8 K+ a( p' z9 ^8 a4 [
8 L( m6 o5 m' X% B" {; O
! N( V& ^* D. ufunction RemoteControl_SimulationFinished() # [6 W E3 o2 U
{ / b& m* [# i: D$ ^$ X6 s7 u; K
WScript.Echo("Simulation Finished!"); |