Example of a JScript
$ ^+ t/ m) I8 {! C6 cvar vbOKCancel = 1;
8 F' r- P1 g$ _ s; \* i1 {( uvar vbCancel = 2; : o3 p u$ U, L+ Y9 I
var vbInformation = 64; / N' T3 Z. k# S/ E' h' K, {
var Finished=false; . v/ V) Q7 T D# ]8 U" b
# B% j# j0 X* `9 K. X1 E5 d$ @var WSHShell = new ActiveXObject("WScript.Shell");
4 c( k2 z) _1 E, Y, I+ v% ~ . w0 u" v/ V5 A t( C
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); - p$ D) y6 @/ A+ i) P* F q
; h' B4 z; k5 R4 _* W
simple.SetLicenseType("Runtime");
1 u. J* G3 o! b/ ]( w: S, r8 E 5 ]) z7 T1 k6 s; W8 B, n4 u2 U; R
try ! j, ?8 y1 W) A0 r; B. i
{ 2 A) M+ j0 [( L# ^% `2 j
// Enter the path to a model file! : ]* k$ [# `1 W& Z6 n) D1 e: U4 `5 Y
simple.LoadModel("C:\\Models\\Test.spp"); * t X* w0 n- d; ]
}
5 L6 U3 L1 B% i" vcatch (e) / ]4 N+ Y# i9 A
{ 9 j# w! M" Z, g/ r/ a; _3 c! A. t
WScript.Echo("Could not load Model!"); * Z: l- Q9 M6 O3 g
WScript.Quit();
# p+ C1 N0 }8 s" M7 \& Z}
2 ^; p2 _, _3 t! D, P8 Y1 k 6 t1 \* T$ |; A" f+ t9 F
try
8 |- G3 U7 j& L$ M4 F) o{ 3 N9 y. [- j5 V$ T; a
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { . S7 p% K* \8 o" I8 [4 S) B
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
7 L* x: o7 h2 E' z9 g. d: b, w if (r == vbCancel) % x7 _) c5 E# q1 D5 ?, M% v
{ 9 Y- j7 l r4 ?2 x; ^
simple.CloseModel();
: h- r) G; e( k2 S3 J6 C3 W# L WScript.Quit();
, E4 ^; o+ B$ c S9 L" Y2 T: W/ i }
9 X5 |3 V6 D. p9 b8 c! M} 1 G T Z4 C; X: N
. M5 J8 C+ m/ ]$ E# s3 B Gsimple.StartSimulation(".Models.Frame.EventController");
9 m J- {0 y3 G a: }
( b5 }! I* }6 |+ D: X- v% }if (simple.IsSimulationRunning())
* V1 ^6 W; b$ d2 b WScript.Echo("Simulation is running!");
, X2 I4 {7 K8 Z2 r0 V4 p) B& \
2 l4 X, m$ _# {# q1 P// Wait until simulation is finished 4 |) g6 @: x' ?8 {" `# W- ^2 o
while (!Finished) WScript.Sleep(2000); 7 m/ D" W4 J* u; `' y! b& P
# T) ]( g' A) |7 h2 usimple.CloseModel(); & W1 N0 a8 F5 m/ h2 Z2 `
simple.Quit();
1 A6 N; n$ b8 i. u: I! ~8 ]/ E% mWScript.Quit(); 2 Q3 t& i7 o% s/ q$ V5 H
4 u! c% p; N) j0 C 7 m' P; ]2 J$ t# H- f1 ^
function RemoteControl_SimulationFinished() 7 W: m( t9 j$ ]# ?4 V
{
/ v7 f$ Z" K- b! p d" a WScript.Echo("Simulation Finished!"); |