Example of a JScript
6 t8 @4 E: B5 U" j: jvar vbOKCancel = 1; ( @1 M& q* D) A" N& K8 Z
var vbCancel = 2;
% n7 [ m: _- j$ Ovar vbInformation = 64;
. O/ J: U8 A, H; H5 L1 S4 mvar Finished=false;
: \. p _/ c2 O8 h+ W : T# J6 r! p0 w
var WSHShell = new ActiveXObject("WScript.Shell"); 5 [* k& u1 z2 L4 l, K) g% a
) L S3 U8 t/ f+ @8 _9 G6 wvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
W4 b" u- v, P. Z, |6 D4 s: u
' q6 O+ Z+ K3 N5 f3 m5 o( G9 g' tsimple.SetLicenseType("Runtime");
+ I! J% M2 Q+ p; _
0 [5 s, x" i5 ltry
6 t& l/ a# h K% L{ + A5 E" U; @2 g
// Enter the path to a model file! 3 {" r1 }6 z$ n6 h( U
simple.LoadModel("C:\\Models\\Test.spp"); 7 D- m* B1 i8 M; g7 @4 Y: G
} , P$ H) c, j n3 l. R/ y* j
catch (e) 1 I' ^, z0 E2 q4 n& e: ]
{
$ [2 t3 z' ^: F( M! v! F+ Z WScript.Echo("Could not load Model!"); ; C- i7 W( g+ ^) T% I! i
WScript.Quit();
# y1 q" s) s G8 ]& B( L}
6 S9 {" X4 q$ o+ h4 O4 ?/ I 2 R6 f* T- k- u% K7 A
try
b& P+ o3 x9 }6 w M{ 6 P! }0 r$ R# h! f; p9 P
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ' h" } V0 I- A+ N5 Z8 i
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 3 l: p0 P- w. S
if (r == vbCancel)
1 N+ G, b) g8 e: J {
8 \7 {% c7 ]; l$ X8 [! m simple.CloseModel(); ' a1 F& p3 f. v! q5 }" ]
WScript.Quit();
2 l: a8 _* F& c9 S9 V } 6 C" p6 j0 w f+ v; g; U! K
} : Y6 Q5 L3 H. J% e; i4 {
( D5 |& |4 _9 a: w" ]simple.StartSimulation(".Models.Frame.EventController");
- Q8 V1 r5 q g
: U, K7 V& [( j% E; @: wif (simple.IsSimulationRunning())
5 R+ v8 U0 Y! \# Y$ T' T WScript.Echo("Simulation is running!");
- X9 w, W2 ]* L' M* y; K2 o , \; s% o$ D! x3 z( |! n
// Wait until simulation is finished
P3 k( e; z9 @: O0 Q6 o# \while (!Finished) WScript.Sleep(2000); & O; X1 c: U- O0 W6 _* s- \9 ~
8 h [8 k H- D. @simple.CloseModel(); 3 [9 R! K' e: i4 h# D% S* I
simple.Quit(); ) J' B+ U% `2 x6 ^* _/ g
WScript.Quit(); ; E7 t: u. z/ j
( p8 w8 X$ h1 e: R) H
: g% `0 w9 T$ `3 M' v. Q' i4 _function RemoteControl_SimulationFinished()
; M6 b& g2 u& Q& L1 M7 L{ % f5 n1 }/ [ [/ ?3 l* k0 |
WScript.Echo("Simulation Finished!"); |