Example of a JScript
, q3 _! M O- q: k' `var vbOKCancel = 1; 6 w. a/ z( v$ G8 y w- p2 C0 N
var vbCancel = 2; & U* O' B7 G+ s: [
var vbInformation = 64;
! i- D: x3 O7 Y7 tvar Finished=false;
: o9 R/ Z r7 X+ A # I% O$ N6 q1 j: E5 Q6 F" `& ?* ^7 J
var WSHShell = new ActiveXObject("WScript.Shell");
" ? j! i$ x4 s& J) p V V3 K7 G ~
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); # _# W" e( b# a7 D( e8 I* a" O# v
$ i+ b, `3 y1 qsimple.SetLicenseType("Runtime"); 5 _7 t/ ?+ }4 x% Y. V
* E* r; h8 W, K4 q# ?3 ]try " Q. w! X; I e0 |7 Q, [, ~
{ $ N: g& i. I( }' M _" a5 K
// Enter the path to a model file!
' L) S! c5 Z# g) n! c, t simple.LoadModel("C:\\Models\\Test.spp");
8 _) N7 S' }" G2 C}
; h6 x' y: [( \0 u( V8 ocatch (e) ! K6 B+ f/ X4 k5 z
{ " P1 [- e" c, k7 S9 q* e
WScript.Echo("Could not load Model!"); ( _; E4 |3 u8 C0 ?! M
WScript.Quit(); * |1 g9 x" o9 Q; q1 ]
} ( q2 O1 s i# F2 s0 O
3 O1 i# D7 c( U x* o Ptry $ m; [2 q; o3 r+ |5 q! P6 D4 z
{ , F7 e9 H3 y4 {* v" D
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
, ` O' ?3 p; o/ a r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); - E2 q# \% x& d( y" [# T
if (r == vbCancel)
U; j5 A* t# x# e+ Y( g: d { H( ~1 U1 f: v+ S
simple.CloseModel();
, [0 f, s! N% Y0 j) \ WScript.Quit(); ! l; T C) o0 ~ W8 @% W A
}
$ s; Y; n6 r* T7 \0 E- C}
7 h/ r! z8 a5 u* Z N. c : J* @4 v, l/ O) s: ^
simple.StartSimulation(".Models.Frame.EventController");
9 L5 O" T- M! }$ [5 n5 E1 k1 n. Z $ ~: C* P5 u; n9 ? g( u
if (simple.IsSimulationRunning()) ^* b& h3 ~6 b" Y3 ~; L
WScript.Echo("Simulation is running!"); + {! n/ @* S+ i) a1 Y# e% d
% m0 i% }2 M# r// Wait until simulation is finished
- ~3 O8 n/ C( e v; a) Zwhile (!Finished) WScript.Sleep(2000); 4 T' n8 l) e8 j. J7 r1 [
1 E; \( W* a3 W
simple.CloseModel(); * [/ ]$ z- n! w7 |, S+ G; F/ Z E
simple.Quit();
3 G# o5 c ^2 d0 B8 F$ f" wWScript.Quit();
# |4 Z2 O% z/ M 4 R! |. v3 B$ T+ o" |& x3 ~
* t% P2 n, w, F" R: \
function RemoteControl_SimulationFinished()
1 u& A2 y; Q0 R% ? T{ + q% w8 r! P8 s! Z" U+ S, f
WScript.Echo("Simulation Finished!"); |