Example of a JScript 2 K. o) T) `: L' e3 l
var vbOKCancel = 1; 3 r' u" f5 @$ A d$ Y5 s
var vbCancel = 2; : P$ z! O* I6 |0 K
var vbInformation = 64;
9 T0 \+ `3 f& H# {3 Cvar Finished=false;
7 \& ~* u: g" S. l $ G( |) T. w" j: ^$ n8 l8 d9 }
var WSHShell = new ActiveXObject("WScript.Shell"); & I! v" m& W X5 U1 J
) ^9 i( s' M4 P' O
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 5 _0 ?! R9 D8 t6 A, n- X6 l
+ B2 O# U# j( B+ o# v& ~
simple.SetLicenseType("Runtime"); # t; p- a' {/ O! g7 O
8 t' f+ W$ M8 q/ U$ M9 y& v
try 7 G/ W& V1 T) a, D+ v2 d# K
{
1 I3 D- G9 t7 G. r+ A" S' P A& | // Enter the path to a model file! ; y. k; W/ l! w* E
simple.LoadModel("C:\\Models\\Test.spp");
- O. `6 ]6 b# u8 z2 ` w}
! |. G* I2 G* \ p s& jcatch (e)
7 ]8 ^' R' y* N3 v, T- z. [{ + S, {2 g. w0 F2 f( q6 m7 a S; U
WScript.Echo("Could not load Model!"); * s8 C3 ^- R, M7 O. D4 n8 F
WScript.Quit(); ' `# ^2 X i; P
} # z/ I9 c7 W' B% H0 Z5 E/ p/ R( {' I
1 T9 a8 H; }, M2 J
try
# w* z8 B# c( l9 B2 C. L* P{ 9 t* e) X. ~5 K: h
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 3 I' V1 u4 t% c/ w
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); G0 ~. d0 m% e1 M& X2 Q1 Q
if (r == vbCancel) , T% ` |$ `5 I
{
. @( c9 x! V$ T# F simple.CloseModel();
! @8 @; Z3 J% H# j WScript.Quit();
/ }3 W! E! @6 d+ g: r% {' m) N }
; S9 L! d. q" q: H6 a" L}
3 _$ T$ o2 d, E N7 j3 R . k1 a s6 S9 F, ]9 j4 ~
simple.StartSimulation(".Models.Frame.EventController"); , g- _* L& h7 s+ n8 k% Y
; C( R" U0 q! ^" f& i( v F3 d$ ~
if (simple.IsSimulationRunning()) , k9 @# k& d9 w# X7 m+ G
WScript.Echo("Simulation is running!");
" m% A: X, O2 x0 ^( @# @
* @+ w; P5 W3 Y" c// Wait until simulation is finished
) `/ d* C* v' S- d5 K/ vwhile (!Finished) WScript.Sleep(2000); - K" w8 e5 X& |5 w+ W; @' i3 O! V' g
/ V& A4 o8 J; m3 I: q0 h+ k
simple.CloseModel();
4 L; W2 j: u0 q9 d& I/ Msimple.Quit();
, O+ o$ M5 B- U c" KWScript.Quit();
0 k9 ?9 l0 a0 J0 M+ o
% m& T5 u: D4 O! }5 P , e5 z7 d N4 T9 M( Y1 O. l$ O
function RemoteControl_SimulationFinished()
+ i% }9 L& Z7 s- Y9 F{ ' b) H( t, u, w, h# {9 s
WScript.Echo("Simulation Finished!"); |