Example of a JScript
1 V# E; x2 Z# b! a/ r$ `var vbOKCancel = 1;
& r$ o1 b1 ]+ q- Q( D2 rvar vbCancel = 2; , g) v+ A, [- {; S. N# n# V
var vbInformation = 64;
8 q+ B! W. G4 p5 \var Finished=false;
& n" N" Z$ v- b; f
8 F' ]2 E' P( f0 b% J2 T: l8 Hvar WSHShell = new ActiveXObject("WScript.Shell");
6 Z9 F& _' C B# a; D6 R " M' D( s0 ~6 E8 W/ C$ z8 a) ^8 [
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
+ E G/ m6 o) \" e: y ( A- U c7 d; Q6 W/ R% u
simple.SetLicenseType("Runtime");
2 y3 w8 q6 k& x: f3 A& k
' d" x7 R9 b* g( b6 Rtry
" W) A* p5 Y1 h' Y3 O& e4 h{ ; E0 x6 ^9 d2 M ~
// Enter the path to a model file!
" H$ n* j2 @4 Z+ e) P simple.LoadModel("C:\\Models\\Test.spp");
' q% ^" f$ H: b} 2 e; h1 O5 Z# n
catch (e) $ S4 G! F( v9 E3 b' T. f9 s) ~
{ 1 q- i* G; E. A7 Y! W2 ^# U; K! m* ~
WScript.Echo("Could not load Model!"); , g6 g1 @& ~: ]! Z
WScript.Quit(); 3 e0 S# m' X; t: ]% n N8 I% P
}
/ g$ b' N; S; I$ g, J0 ] 4 W# M( F' C1 s! h( ]: |4 f2 v! r
try , ]0 j- W3 ?1 M
{ 7 @0 Y$ ?5 i5 I ]
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ; s+ [ n0 a5 I* b( N
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); & Q. q, x! \% d h( y" k0 q/ A% D! k
if (r == vbCancel)
9 J% p7 q7 k: g/ V { 0 h2 o. E4 J% S/ w) w) E @
simple.CloseModel();
' s& ]; b1 O# U) L* S WScript.Quit(); 8 [/ v- h/ l$ x7 A4 w8 r
} ; } \- j) L: m+ S9 M
}
# z" d: E- W2 q* ~2 Y& z
) R$ I5 z( v# V; m9 c' vsimple.StartSimulation(".Models.Frame.EventController");
5 c2 O# B( A: y- t: ~ T9 Q1 D ! o( Z5 `9 v, `
if (simple.IsSimulationRunning())
' _+ B/ }. d& s' Q% F WScript.Echo("Simulation is running!");
% I9 l5 o" T; k) _0 R$ Y/ n6 N3 ~" p
, d! i% A5 r4 a W) K- i// Wait until simulation is finished
3 P' R; T# ?" f# s4 I% Q$ Mwhile (!Finished) WScript.Sleep(2000); + h. q1 y& c# a4 ~/ W/ Z
/ p$ ?% u% f0 T1 `simple.CloseModel(); . o2 B5 i8 k- J3 K" @2 K/ p/ Q
simple.Quit(); " F9 ?9 N4 c' |5 d! n
WScript.Quit(); 2 N3 D. B* z# M% c8 Z
`+ s# B7 D& q
0 n8 [/ l/ u1 K0 Mfunction RemoteControl_SimulationFinished() ' r1 r8 t0 L- @; o2 n
{ 2 _% f5 N4 k! Q. l1 _
WScript.Echo("Simulation Finished!"); |