Example of a JScript
7 N! E% o/ q8 g7 G. b4 o& ^7 p/ avar vbOKCancel = 1;
8 _; A* A9 ^4 T1 xvar vbCancel = 2; * C1 @4 x6 l. ]0 O7 ^5 ^
var vbInformation = 64; ! Z2 M& m3 j( M' T; |! K; Q
var Finished=false;
+ R. q: m$ Z- P9 | F
9 k! j, K% B; ~var WSHShell = new ActiveXObject("WScript.Shell");
! m* [9 j' @6 [
5 d1 ?% k& a5 ?% A! k: y/ vvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
0 f4 P# S5 }6 Z+ { ' L4 ~/ Q% Z2 d* K
simple.SetLicenseType("Runtime"); 0 B, S1 |% e0 @. L1 k5 V
, v" K) c1 f1 d* b) o
try ]: D( w; `. ?. Q# G) L
{
3 Y$ j% x/ d! j2 x% \1 S* R: T // Enter the path to a model file!
, Z$ f- q( Z) B. D! w simple.LoadModel("C:\\Models\\Test.spp"); 4 c% ~4 M. p$ q8 q8 o8 y( Q
}
+ [0 K( p( x, c$ X6 |3 vcatch (e) 5 a$ i0 b& j6 v1 P5 u E
{
/ n5 c) V0 n' Z WScript.Echo("Could not load Model!");
' M2 S- i& m* y WScript.Quit();
# ]+ b9 m5 Z( q2 _. Q2 x5 ~}
3 Y! |" x. ]; U6 J! F5 S: ?$ D & F/ \# ]% X: i8 l0 `" o
try
) o/ t3 u$ B1 q# E{
/ q- T7 D: @% x; o simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { # K, {: Y1 G$ m1 l$ Z+ S
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
% g+ v& e p9 [6 @" C2 L# ] if (r == vbCancel)
/ `& @. l# Z+ l" s, o; C+ } { ! X9 b& Y0 m p; g" Y
simple.CloseModel(); ; a) [5 ?& m S( h- O, o
WScript.Quit();
+ c* I& J) @0 R& q } - h* {" z, B9 x0 M% Y3 C
}
8 y; o+ i/ X& M9 R% q. C 1 `: c5 K/ H7 o( `. u$ S
simple.StartSimulation(".Models.Frame.EventController");
2 B1 i( Z, l9 D9 i8 D . F, A, b: g. A5 o3 G5 }
if (simple.IsSimulationRunning())
4 ?2 A" C: b9 r. I3 U- M5 ^ a WScript.Echo("Simulation is running!"); 8 ^& L: P: @/ r2 G0 a# g
: r; ^& G4 N- Q7 c& i- ^
// Wait until simulation is finished
; Z4 R! d* L0 b0 a0 ywhile (!Finished) WScript.Sleep(2000); 5 [4 k; L* e2 @/ V g4 K' g5 |" @
* y2 f t |+ H6 V! r
simple.CloseModel();
% z* I' {2 v. V6 b5 I' bsimple.Quit(); / ]- M- {0 W0 d' w+ M0 @# M+ Y
WScript.Quit(); 7 B- S7 J. ?& j2 L- q$ T' b
& H }$ M2 O" U6 [5 s
( Y; f. ~$ q$ C% c4 R, z+ g8 Hfunction RemoteControl_SimulationFinished()
V# h% T; W9 @2 @{ ! X s% b2 S6 {5 S4 L3 o+ m
WScript.Echo("Simulation Finished!"); |