Example of a JScript % P* L% o. ~/ I6 S4 n
var vbOKCancel = 1; ! P8 `, C: }! K" H8 `0 y
var vbCancel = 2; N2 ^7 K) P2 _
var vbInformation = 64; , c" Z5 |; F8 y3 n$ p7 z
var Finished=false; & m/ Q- y4 ]9 b* G
$ G, N; e6 H& i
var WSHShell = new ActiveXObject("WScript.Shell");
$ S5 K }+ a. e; E J 3 R! ~% p* x: T) A# R
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 5 C Y' q& C, }6 U& L
8 s4 ]! S% o/ T, H6 B: zsimple.SetLicenseType("Runtime");
1 s7 F3 q: z8 @, q! \/ H . e$ c* ?! X, k& j. Z0 C: l
try
8 d3 S9 S9 l$ E{
( f- t: h J* A' f# O3 C // Enter the path to a model file!
) d4 C6 _; n% M$ G2 v& B1 S simple.LoadModel("C:\\Models\\Test.spp"); 1 F: _8 s {8 s, V$ h& c
} 1 \( I/ w# p6 Y% V$ c
catch (e)
( j: ~# ]. q# Q5 @9 f B/ t{
7 q# O P4 H" A4 e, \* K WScript.Echo("Could not load Model!");
3 z5 C) C: m9 j) L4 b% b1 g" E/ n WScript.Quit(); 1 t d& S1 m& ^
} $ U; E7 `9 G5 K" T( `, ?
/ y1 Q( ~8 k. [0 C' j P A
try
+ x, A/ `+ p" R! J3 ~. L1 M N{ 7 Y/ @4 Z" h% e" L3 V7 A( Y
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ) J) i8 M* B4 b8 I
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
& u1 k, a3 g" l" Q2 P if (r == vbCancel) 0 F1 ^4 w: ] }& j( D& I+ l+ K9 ]0 w
{
) O A8 l* Z* p$ S simple.CloseModel(); : x. _# A# I$ O" X
WScript.Quit(); ! e+ f9 d: l5 g3 s# O5 c C
}
0 b8 j7 ~) }- |$ R$ M} 5 P7 Y' g; Q* r5 S
& o Y/ G0 c# M
simple.StartSimulation(".Models.Frame.EventController");
' b. W+ g/ A% ~$ J/ _ 2 ~! r% r. R* M+ k) Z( U# B" o- M
if (simple.IsSimulationRunning()) : W: R. x2 ? V: O" ?6 ?6 R
WScript.Echo("Simulation is running!");
! q, e2 |# j. y s9 w7 {
% O; U* U; g" ?4 f// Wait until simulation is finished
& a+ T5 r5 O( O$ ]/ T' J) ^# g' vwhile (!Finished) WScript.Sleep(2000);
8 e; s; c- t6 d! u7 \" b C, x " D/ w7 O. k0 U. k& H p
simple.CloseModel(); ) A+ a' A; U* B1 [) ~
simple.Quit();
. ?8 @! k- I: fWScript.Quit(); ' x1 F- S6 w: t$ A$ q, h
2 z- ]1 u" w" }, m% ]8 k
3 t, C* k' g. {2 P
function RemoteControl_SimulationFinished() " u3 A4 G6 L# N5 e ^
{
+ M5 c4 d$ t# L. s$ f, e WScript.Echo("Simulation Finished!"); |