Example of a JScript
1 S' x3 O; F4 G* a, y" f ^var vbOKCancel = 1;
; J/ j2 i( v! H( r4 e! a$ hvar vbCancel = 2; ! P: S! g3 O# Y3 S* }+ l
var vbInformation = 64; / p8 }; K- Y9 X$ j
var Finished=false; 6 I) H2 C5 |# P7 E' B0 G$ M) }
* |' m( g: s( p/ j! }9 b/ qvar WSHShell = new ActiveXObject("WScript.Shell");
# u' ~* U: Z6 U8 Y4 L
8 `8 ]$ g' f' n, g uvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
) j, K/ a# @- B8 ` # A- m% y v5 J6 H6 l, w5 a5 F+ @ i
simple.SetLicenseType("Runtime"); % ~$ [3 i$ g$ t. `2 S$ Z) L) w
# E3 O; p: E5 d9 f
try 5 ~$ H f. ?4 A. u! }5 l, e( x
{
. x( A' x* M, ]% c9 y1 `, g4 Q // Enter the path to a model file! : e& W2 Q E( p2 a
simple.LoadModel("C:\\Models\\Test.spp");
1 T6 d; x* F/ y J6 Q9 R, ^}
( K& J9 Y" [: T# k! M+ ~' Xcatch (e)
* C* P# a2 Z: X{
6 M( x+ `: K* O" N WScript.Echo("Could not load Model!");
. j0 Z5 m) n& f$ h5 o WScript.Quit();
' f: p: U% P V/ ]+ B}
4 v/ n0 A! R* _: E/ x
. Q2 a$ _& t& y& I- ttry # i v% [/ d1 }4 R" |
{
# o' R: }; O; X2 y. s$ S" F simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { & @" c/ a3 |' L
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 2 }( \6 f; y+ n
if (r == vbCancel) ) ]9 Y: _& u* p) s
{ 2 _/ ^( t9 h/ C! ]/ n
simple.CloseModel(); - X( L/ w/ u. u7 x2 J" @3 _2 g
WScript.Quit();
+ b2 D* O! n/ F }
& s) B$ g: ]9 y8 `2 U} ! T$ O2 [, K1 ]5 Z5 z
' ]" O, _6 q5 _* ] C6 y6 m
simple.StartSimulation(".Models.Frame.EventController"); 9 e5 y% R8 @7 }6 w7 d2 \8 e3 V
, h" `+ q' y2 ]" e) O# I8 C. Z
if (simple.IsSimulationRunning()) 6 p& |$ o0 q8 P, o# \* G
WScript.Echo("Simulation is running!"); & |+ `9 J; @" O
0 p9 L6 q) G' b; e4 ~0 ^: E
// Wait until simulation is finished
$ k% w: I8 p! {* |while (!Finished) WScript.Sleep(2000); , S! \9 R3 T! H/ J! T% Z
3 _$ W! T* J' A- F: c9 Rsimple.CloseModel(); & Q6 e ]' I" Z; R& @& A
simple.Quit(); 8 p" M' c( _# x
WScript.Quit(); 5 U, L! u: l4 B; C: A) _
. S* S# C1 T* m. X3 L/ G
) R3 g, e8 k9 q2 o gfunction RemoteControl_SimulationFinished() 0 G) ?# X& R& x
{
% ~: h; x* T; |8 |! F1 ~4 C5 N& p+ C WScript.Echo("Simulation Finished!"); |