Example of a JScript
& }+ e+ A. {8 C( wvar vbOKCancel = 1; % P$ q' z; w$ Q% }0 ^2 x
var vbCancel = 2;
; U; p5 M% n4 q l* mvar vbInformation = 64; ; r4 ]* a; P: Y$ g
var Finished=false;
, a! k4 U5 }6 d' A
( V7 T& y( a$ U; s; t2 a( zvar WSHShell = new ActiveXObject("WScript.Shell");
' a% K% k6 I5 [& U* \ ; P! Q4 P) V5 G& l
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
/ N2 M6 z# h6 Z4 C" ?
& [# m# l7 x+ W1 h, \: Z* H9 _& Q% Rsimple.SetLicenseType("Runtime");
# W. ?" ^/ ? `# a# x* J8 {3 Y
7 a" t; l: I6 _; Gtry 7 t5 s- o5 a* \
{ 2 N, A, v' m3 X H- W
// Enter the path to a model file! 3 W6 ]3 O/ d9 _) p* n" U
simple.LoadModel("C:\\Models\\Test.spp"); ) [, p0 [; [- Q: A5 n9 y/ D/ R+ X
} 5 ~: |( A3 y* N3 [4 m- B
catch (e)
: t& L4 [; u. y0 l% L g5 |{
% g2 L( C" Q- W. E WScript.Echo("Could not load Model!"); 6 {6 V5 J/ g8 x$ l9 _1 E
WScript.Quit(); " a9 Y( l7 U8 v
} ; h7 o7 H/ ~3 W1 Y# M
: T8 x# |- p% ktry 8 d+ }* v7 q) N
{ : e, A& F7 R, A/ L
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ) \; J; W* N! e4 ?: k
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); % D' X6 p5 d' C" U6 z/ D2 V1 s
if (r == vbCancel)
) q$ Q( [+ A% R5 C% G) e! `! f0 D1 X {
# u! A s& a" u* I+ p3 p0 z) N7 W: K2 W simple.CloseModel(); 8 o/ u; z9 {4 X8 F( ]1 D+ ]1 d
WScript.Quit();
7 w: `( G( Z1 Q7 ~3 ? } # [% i9 R- o- J' X+ E" |
} : a- b9 v7 Z% y1 W+ b. v8 q7 V
2 b2 E/ a$ Z; b C
simple.StartSimulation(".Models.Frame.EventController"); 5 T7 y1 _* t1 S$ V- p+ K$ J
/ r Y" h G2 W gif (simple.IsSimulationRunning()) - _! H5 J, m- M0 w. b
WScript.Echo("Simulation is running!");
! e, ~5 I/ F$ H4 z 5 K) \+ y, i: M$ C; K ]) ^
// Wait until simulation is finished 9 h7 `1 R+ i. u" L
while (!Finished) WScript.Sleep(2000);
: o4 b6 c8 L% E
: W4 t2 p0 F' a; O. osimple.CloseModel(); 7 X4 T% z# i& _4 q+ b; Z
simple.Quit(); & o9 }" R4 B, t0 d' u1 i( {
WScript.Quit();
3 X0 z1 L' a r% T3 A4 N6 G: } * t! f8 |: a2 O* e/ s
! Y0 p, A& B( V/ E" ^function RemoteControl_SimulationFinished() 0 W8 p( J; s: L2 d# [& h
{
, @0 ^- j) [8 a2 @ WScript.Echo("Simulation Finished!"); |