Example of a JScript
5 ], N& I' V: `var vbOKCancel = 1; , F% P) w- A% ^( `
var vbCancel = 2; 2 S9 G, v; D. K, y, q
var vbInformation = 64; 2 O& h& L& e8 P) q1 y
var Finished=false; & X. C* {3 W* g
9 ^1 @/ s4 ], z" G* A7 O/ q0 Q3 |
var WSHShell = new ActiveXObject("WScript.Shell");
+ X. q; K5 [/ Y( R2 O
' d; p, X$ b, svar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
. a* |7 J' R: ~
& i- A9 l5 a& K% k1 N2 _, qsimple.SetLicenseType("Runtime");
. z& u. V6 z6 @$ H( @# m1 ] - j4 ~7 F& B9 o; ^
try 8 V+ Q1 O1 _2 G9 w q
{
" z: i) p* j3 u* { // Enter the path to a model file!
' g- m: I) H: t$ V9 _7 @) D simple.LoadModel("C:\\Models\\Test.spp"); - [: t5 _7 o1 r1 E
} , Y# B' S5 Z; Q6 _
catch (e)
( X) J$ p# j) Y5 k{ / ^+ x7 ^9 C$ k! n/ S6 ? H: e# q6 t
WScript.Echo("Could not load Model!"); 6 C1 ?' t& s k+ M; _# `3 e
WScript.Quit(); 8 b. \& V6 w# f& V- q1 }
} : D: j9 |; A+ R" O0 k1 a
% M. ]8 c8 n. ~2 x7 qtry 7 T, ~, m; H+ K+ x- R# o) y* I
{
4 X* ~/ Q3 ^: u, y simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
! ~7 C8 J; Z$ Y" A9 ?" Q" M r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ' `( e4 j* f- h/ [0 P
if (r == vbCancel)
. c# W6 C* L$ C6 i$ S, F {
* a% C; m2 @2 t: A- q) G3 p simple.CloseModel(); ) w' ?- D! d! y
WScript.Quit(); 7 i# l P" d' h8 {3 Z
}
* Z% K6 o7 J$ [ F6 w' [2 [/ s0 B}
0 y7 O: U" f4 T
, F7 r# n) @3 R* c' x) Osimple.StartSimulation(".Models.Frame.EventController"); % M0 a" D7 q: ~6 b% K, r5 Z
. t2 M4 `, H6 j+ B0 h! rif (simple.IsSimulationRunning()) $ e/ {7 | w+ D; ^+ W
WScript.Echo("Simulation is running!");
+ n& n' U& q( p
* |7 @: M# J# W// Wait until simulation is finished ; ?9 w6 a( o. ]' q/ ]
while (!Finished) WScript.Sleep(2000); 4 g; t$ c( X' d( b* T" Z$ @2 P
! d4 { x' X) V1 i' M# Y% a" ^
simple.CloseModel();
6 p1 G2 _1 \- l/ O5 f/ jsimple.Quit(); & D1 K2 O9 {# `7 x( O) F
WScript.Quit();
* E8 Y; o. l; j+ B# |$ P: H3 _! c0 I 9 x$ J) A X8 a/ {. Z8 E
1 N N4 d7 ^9 r6 \function RemoteControl_SimulationFinished()
, A# K: f5 I+ c( r1 O! ?* f. W2 w{
1 ~. u+ H: P0 x* g WScript.Echo("Simulation Finished!"); |