Example of a JScript 4 R( L1 w0 M1 n$ o4 a# L1 o
var vbOKCancel = 1; ! V) V6 v6 z, A& R$ j& T: l% E W
var vbCancel = 2;
4 K* Q' o! ]& Vvar vbInformation = 64; Y8 r2 c& C( ?4 h
var Finished=false;
2 W/ K5 r7 x. u, t% {: ]
' s3 ^- G: S% ?var WSHShell = new ActiveXObject("WScript.Shell");
* P$ c2 K, u/ a9 \- v! \ 9 z' ?3 T' g! j5 p8 ?
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
: N3 y5 Y& h2 Y
) v: Y, [5 A0 G S' g6 p9 N) Isimple.SetLicenseType("Runtime"); / S% M+ p2 Z: E h, b3 r8 ]
0 I# `+ C5 G4 O6 K
try
6 U4 f! `5 V$ E8 y{ : Z. r( N" Y* Z( y8 s; J
// Enter the path to a model file! ; F0 `! F& @9 @# E8 Z( e: H
simple.LoadModel("C:\\Models\\Test.spp");
( n2 J2 t" V* X5 N/ l}
3 n1 R5 p4 t; j0 S" |catch (e) " J: G4 _% O3 D, _0 P1 M5 Y2 |
{
* K5 G( |, j" L M7 w" k/ n WScript.Echo("Could not load Model!");
P% g# W* U2 L WScript.Quit();
7 b3 C2 x. e P& @8 u} 2 Y* Z( K" I: I- _+ v: A; V C3 E
1 c7 w' V6 n0 Z: B" R$ S" Wtry
0 p3 D4 a9 W1 Q: `. U% H3 E{ % M# Z7 R: B7 M* i0 k$ f$ H
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ) h3 Q$ |/ h. w/ a: ^
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); - A G: _! B, Z4 _9 v
if (r == vbCancel)
& T; t( T# X1 s; y+ e) y { 5 t+ ~" `, I: h
simple.CloseModel(); ) A# G' }+ |! H! n; G1 E
WScript.Quit(); 2 a: T, t' ~) x1 U3 u/ d$ ~
}
& I7 w7 V7 o4 I}
5 t5 d. O: y$ L5 x' B8 V! ~
+ G/ n: [# j- ssimple.StartSimulation(".Models.Frame.EventController");
8 q5 k% [4 N- W3 w7 s6 o: l% O
2 g; D: Z$ o, h6 d: B- D- s3 ]if (simple.IsSimulationRunning())
: Q0 b. p6 I' Z1 |3 R WScript.Echo("Simulation is running!"); : ~$ [0 F- J# e ? k3 [' {+ |
+ w Z' _( }" S h& Q! y5 k- r0 l// Wait until simulation is finished % [1 G* X; Y; D9 S+ W4 d
while (!Finished) WScript.Sleep(2000); / _' x2 R. b8 H% V# R/ k
8 _, F4 W' }" @- O3 P7 ^/ @; a
simple.CloseModel(); ( Z: E6 v4 @1 L4 m, e) H. F3 `( e$ b
simple.Quit(); 8 }2 M2 h- P- ?! l# C6 P/ S
WScript.Quit();
: \* ~2 N* \" \ & ~( `. d1 Y6 D# r7 M
/ d" L. e8 E; T$ B3 bfunction RemoteControl_SimulationFinished()
3 v# K. K+ k4 L0 e/ T5 ~{
3 S. m/ o2 U" S' O# i/ Q# p1 I1 B WScript.Echo("Simulation Finished!"); |