Example of a JScript
+ x: z& G7 e) z6 V+ _var vbOKCancel = 1;
; ^2 o# y8 o" J" Cvar vbCancel = 2;
. Q0 _- R" k6 T6 w5 kvar vbInformation = 64; 6 e% l7 y, k1 Z u& D" \ c& [) \( O
var Finished=false;
: w5 O7 i: o, Q
2 n& T7 t" W3 e# q0 g' {8 lvar WSHShell = new ActiveXObject("WScript.Shell"); / P/ D* `5 x: n
0 ? i( _. O9 |0 J5 V& g& c4 W( Wvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
( _* l5 K& b- X4 S 0 x# T% v$ ?7 @, y1 K h) C
simple.SetLicenseType("Runtime");
' }- [8 Z: K9 ]4 p+ y+ K
& c+ \" T8 C5 W" S! e( M2 A/ ~5 x' Jtry 4 M7 a' b2 I+ @; o* Z" A
{
% Y# \) l) Z$ b+ |+ G9 u# v' G // Enter the path to a model file! % d! G7 R2 I8 K7 {
simple.LoadModel("C:\\Models\\Test.spp");
. W5 B: M# r: E) Z}
$ {7 P' c6 H/ pcatch (e)
, p/ ~# \$ S+ S{ x2 y/ D5 j3 J) W0 ?
WScript.Echo("Could not load Model!");
8 r1 H( n/ n6 w+ R+ I WScript.Quit(); 8 h9 v4 ]. v. W9 L
} $ I. ]+ p' g; R( ?9 P/ k
0 l h& e0 s4 G! Ltry
7 |$ ]& I6 D1 \9 {0 Y{ 7 ?, F8 q6 W$ B$ t
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
# f: S, y0 p6 y' l: M1 k" m r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ) S0 }& S4 I A5 L
if (r == vbCancel) . L$ B* @( {6 c$ n& `3 }
{ 5 j7 ^# ?% N( t+ p. `3 u
simple.CloseModel();
2 e1 t) C: X. J' K L3 H5 J WScript.Quit();
& A8 E- d5 S' D* T6 {) n8 S. B } # ^1 R1 C5 E; {" b$ H* a5 H5 x
}
! g" M0 a( A" x3 w: z& W
) s2 m+ X: T) r( r6 b& osimple.StartSimulation(".Models.Frame.EventController");
# V \' B, d: s5 y* n- [; f ( G: {) Y. h9 `4 |$ c
if (simple.IsSimulationRunning()) 9 e3 o- A3 `0 h: _2 m8 m5 h
WScript.Echo("Simulation is running!");
# d$ Z0 {" f5 K6 E: F( R( m, q
# ~) M6 \7 J& L0 {- |4 h// Wait until simulation is finished
8 F: M9 G: V* ywhile (!Finished) WScript.Sleep(2000); 8 j" q1 u+ J/ u7 z+ y% T, P
; S, V9 k2 i' G/ T9 t- @
simple.CloseModel(); # `( w( C4 {8 W P3 s3 c
simple.Quit(); # ]8 `, r% B$ m+ T
WScript.Quit(); - I2 ^( f$ X# L4 j# R; n2 N4 `6 }: m L
( r2 L4 B1 p, y, y! l9 p* H2 J " W1 Z; D- b s* O" S
function RemoteControl_SimulationFinished() # f9 ~4 s* S8 s, M7 ]: h
{ & ^+ g }0 _) ~5 R8 D2 L7 Y% R
WScript.Echo("Simulation Finished!"); |