Example of a JScript |: x% |) D& {+ t# i
var vbOKCancel = 1; 9 s [" p7 ?- q, f5 b5 ~; f
var vbCancel = 2;
+ a. i* G9 J, T7 N9 F* E3 G' |( Wvar vbInformation = 64;
: ]: {% o! v/ m/ n6 S( |4 i$ R9 |var Finished=false; 3 M1 s2 H0 @1 b- p' E
1 i6 k$ g& c/ gvar WSHShell = new ActiveXObject("WScript.Shell"); 9 e: R" r/ d& @' n( T: W+ v4 x
% D; d' ^+ H: T4 |2 m) M. W! a( b. ]var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
. w7 w% g# D |/ i& Y9 V : j# n' E f1 t/ u9 k
simple.SetLicenseType("Runtime");
Y$ q6 c- F+ i ' B/ q3 u! W. i* Z4 v x
try
* v1 S9 B: d4 q' ]4 A2 {/ g{ 1 j7 @. _3 X8 R
// Enter the path to a model file!
, M5 {) B9 n3 o0 Z' S2 T simple.LoadModel("C:\\Models\\Test.spp"); & C6 S2 R' w7 e3 ^' ^/ g- s
} ' k5 D+ M( W6 u; K8 j
catch (e) 6 t7 q9 _2 g$ R
{ ( S, G/ A: x9 Z& Y6 ~ p9 Y
WScript.Echo("Could not load Model!"); ' s( N4 m" i+ G. u, ?8 u
WScript.Quit();
& F& `4 @4 x! k1 o* v}
8 y6 B2 a# p6 Z; R% Y/ J/ U5 @ - t9 T: V9 ~( v# O
try 6 ^ m; _! Z9 U7 J1 _* f, u, M' a
{ / B5 s0 o! a; s
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { e8 ~0 o8 f+ x: T1 e) x' K/ Q: u
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
6 d: \) G$ y K; ]2 ]# E: L; u3 L \ if (r == vbCancel) 4 N8 o8 u" y0 _1 X- B% {
{
6 k. l$ f* r* ?, A- ^ simple.CloseModel();
% V& b" v0 I" R# @8 @+ M& d. K6 s2 F WScript.Quit(); 9 Q6 P7 F* ~( t
} % @( O z/ b2 }
} * A. M0 r+ \; k a9 _9 k* Y
5 L4 |& r& D5 x$ E( b3 _
simple.StartSimulation(".Models.Frame.EventController");
0 ]: s6 q- I5 w# v! I' H9 _
- B# ^$ s- g4 _7 lif (simple.IsSimulationRunning()) 0 |% ^9 I( ^% T! z) E, c
WScript.Echo("Simulation is running!"); 2 h( L8 p! J) Z* K7 U
6 z. |% v* ], E# o
// Wait until simulation is finished 7 m) r' Y$ y! A! Z
while (!Finished) WScript.Sleep(2000);
$ F- C* w3 g0 M' e2 u7 B" b% ^ * f7 f" H2 N: m" ~0 z
simple.CloseModel(); & l1 B: N- ?3 M) T) R2 D
simple.Quit();
! W# b/ k% R5 t) i; e8 n. ?+ U, fWScript.Quit(); : n6 L/ @5 E. C# c* t5 o a
: o% Y* b& E g! x- \2 a( h% B( k
/ ?% V W D+ h- ^function RemoteControl_SimulationFinished()
% I( X9 Y! ~' L9 r{
; m# f; q2 q' c& c! @: e+ V WScript.Echo("Simulation Finished!"); |