Example of a JScript 2 o. C2 _! W: B; ~% ?; m; i3 a0 O
var vbOKCancel = 1; 7 u0 Y& ]: c! X) X2 {6 u7 U
var vbCancel = 2;
3 [- M! C' B0 L5 S$ W, Yvar vbInformation = 64; & ]: l8 |! V& U; b
var Finished=false;
; \8 d# T$ m% j9 g; \- B
# @1 G8 Y' H- ?7 u1 Ivar WSHShell = new ActiveXObject("WScript.Shell");
, b" t1 W2 k* x R
4 Z% B6 j; H8 K! G7 I2 Q( V) Jvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); & E& Z+ s' U7 B8 {. s& C" c1 G/ c
N ]# w' O+ \4 v
simple.SetLicenseType("Runtime");
. d% E, H; R4 X* x+ }
0 _ j9 F8 v8 ?8 l, C, L rtry 6 y& |. g v* d3 z) \
{
! C/ Y/ M8 B+ Z4 M: g5 q9 N // Enter the path to a model file! 1 Q+ X9 ~0 z. Q t! D
simple.LoadModel("C:\\Models\\Test.spp"); 9 d/ a n( s1 c4 g
}
% V0 q# L$ k2 i. qcatch (e)
; s3 j2 X3 X; @( {{ : C: u: C/ f$ g6 K M
WScript.Echo("Could not load Model!");
) q' i9 I2 g0 D" F WScript.Quit(); " O/ }" ]) X: l* `+ P& a! b* S& r4 v
} 2 ?7 h* ~3 D4 {6 |2 r
: f3 W: F" c6 M$ }; N! |/ T
try
8 F4 b$ }0 \7 O0 `3 y4 B1 Y{ # g/ Q: J% Y) f/ D
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { : X1 }9 _$ r; g( w
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
& f7 a; ]7 \; J, y6 z2 M if (r == vbCancel) ) v9 ~' P' V- T7 _
{ 1 h7 O! B% X; o" O
simple.CloseModel();
( c5 J6 f# y4 ^, p( d WScript.Quit();
3 J7 @% A) W4 Z: b7 G% ~* R4 E }
3 b1 E8 q a7 v( d) B0 J}
' ~; W) \' R4 W( D& n
8 h0 W! W- c2 A1 isimple.StartSimulation(".Models.Frame.EventController");
# q3 p7 `5 A m9 r/ L0 {1 a2 g$ U + M9 b, x% A( k3 D K( d
if (simple.IsSimulationRunning())
! k. r, }0 w( W9 B$ U' i8 i WScript.Echo("Simulation is running!");
$ R" g+ B9 Y& D( O& J1 x
. h, |* W- f' g2 v// Wait until simulation is finished 4 a1 a7 {9 c/ L) f& @' w1 M( X8 m* o
while (!Finished) WScript.Sleep(2000);
; _' i1 i% d: ]" a [ / ? _- i' C5 R9 Q
simple.CloseModel();
8 b3 ?* Y+ w* @+ W; p8 E$ e& nsimple.Quit(); " x( u0 q; @; U5 }8 t
WScript.Quit();
7 u& C# b8 I! [1 k( s
/ H, G- f2 Q+ a. d
S% b" w' c/ g% q1 _function RemoteControl_SimulationFinished() ! b4 p; ~& y* I. }
{
; [( q+ l6 S3 B WScript.Echo("Simulation Finished!"); |