Example of a JScript 2 D. R1 T& o1 T) C9 }% q
var vbOKCancel = 1;
% [! A% \1 I' M1 R6 ]var vbCancel = 2;
7 _9 `- x( m b9 Bvar vbInformation = 64; ' b9 ~+ I9 v$ [+ B
var Finished=false; , s- S. \/ P7 `% V0 m
4 z1 Q6 G5 `, T3 ^3 d" O( u; Ovar WSHShell = new ActiveXObject("WScript.Shell"); 6 j$ N# e4 l+ U$ V; `
. O, Q# W( ?( ~6 C* V7 |2 zvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
% V7 t& A: N) e: k4 \
* T, P/ h( m, E/ A" Bsimple.SetLicenseType("Runtime"); 6 e6 s7 B1 M# h; e$ U" X: p! n
9 t( s- U- D$ h+ R; Z6 I xtry
$ m# C0 g0 {( K- V{
$ `/ O; i8 ^- C // Enter the path to a model file!
" N* i. v/ u |2 d simple.LoadModel("C:\\Models\\Test.spp"); : e3 h2 A. L# L3 x
} # e( i/ O9 @) S. e* M# e
catch (e) : `2 ~! g, [3 A# \1 v. P
{ 0 v! t; f* p0 X
WScript.Echo("Could not load Model!"); 8 O5 g3 M4 d; h. Y2 z' _' V& p8 t- v7 f
WScript.Quit();
. }9 x" Z/ |) R* g} & Y. N' c# q- H' y. W% c+ {
% q! ~8 C1 w3 c6 k
try 0 E- g$ _5 E0 V1 _$ O* T) P
{ F; ^, x& g" S- |7 p
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
- b% K; {% v" c5 b; k! M w9 N r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); # M1 \, ]: @; F4 z! O
if (r == vbCancel) ( n4 X6 d* {( W& }1 G
{
7 L1 ?5 U: t [& R0 @6 f simple.CloseModel();
% k, F7 c0 q9 r* k* K WScript.Quit(); ! X% P: M8 z% F0 G
}
- d* S1 u! K' J- z+ }}
# c# ^; C4 ?! s) ]# L* O, B; l ! ?" }0 W3 Q! t: F9 ]
simple.StartSimulation(".Models.Frame.EventController"); ) A$ k$ x( @* U3 {
/ J% R! H+ ?1 `' b8 }0 v# m8 o5 ^
if (simple.IsSimulationRunning()) ' u1 Y3 h7 ]: U1 J& @" U4 B
WScript.Echo("Simulation is running!"); 7 f3 G3 L( I G2 U% R" [
: D' J' K n }" p5 M) z( [// Wait until simulation is finished
& [; n, b- p+ l, x' j: h6 |2 H: Wwhile (!Finished) WScript.Sleep(2000);
1 m [" y9 p3 K4 M% `. q
3 ^# R" ?' k1 Xsimple.CloseModel(); * t' m* S- W4 R# s r2 A' b5 N
simple.Quit();
1 d0 ?1 i* ~8 W' y3 D' A% K2 m- YWScript.Quit(); & C" h+ _0 n) v* J3 Y3 R# l- R$ P# B
! u# m6 }) o- d' h. G f
" {# V% `, {& b, a) _/ x" Q
function RemoteControl_SimulationFinished() 3 A& r! l% t6 k* `9 p
{ 1 l% [1 }- ~4 ~& g
WScript.Echo("Simulation Finished!"); |