Example of a JScript 6 h! g. b! S% m& i9 b0 ~3 i( p9 B
var vbOKCancel = 1;
7 ~. [) ~1 k& p. q) |3 @' K! d% ovar vbCancel = 2; 3 ?0 L# S* _7 `) [+ K, p/ R
var vbInformation = 64; 5 L+ C7 ~4 k9 p
var Finished=false;
& x" ~& R- ^* R 0 w( h2 {1 l" R5 f2 I3 w
var WSHShell = new ActiveXObject("WScript.Shell");
2 ^9 [8 a- a! |# ?6 N/ R& M
) D. @, P" l/ u2 ^/ rvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
" Z% H' o9 G) t8 H8 C
7 C! K; c& M* k+ ]9 G" Asimple.SetLicenseType("Runtime"); & h5 H3 Q5 m# N1 ^+ F2 N
^$ l2 |0 A& g' E+ X
try
8 ^1 P! p. Z* v: Q{
! |4 k# T8 ~ t( a# |3 o7 Q/ I // Enter the path to a model file!
) v* M' Q( A3 w simple.LoadModel("C:\\Models\\Test.spp");
, d j$ j# ?( d( n d} 6 B2 n6 I7 l T
catch (e)
& Y% b; s; o6 d) u8 `: Y6 k{ ; w( `2 T- O8 i( y( e
WScript.Echo("Could not load Model!");
5 V% t7 \. o/ H WScript.Quit(); & a/ w! W f( g* S1 {
}
% ]: k, Y7 D2 I1 G ! V) |/ j/ o1 e8 t9 G, @3 o
try ]$ J7 w) k" o& F5 e' U
{ / v: Y* f# Q; w h j& x, n( g
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 9 u7 s* M6 x! w0 t2 u, W
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
0 O3 q5 f$ j1 O% L if (r == vbCancel)
, K4 P" v5 `! T2 j+ {1 ^ { 9 ?' d8 x4 q) ]: S' P+ M
simple.CloseModel();
5 M1 l Q& ?4 X+ s& S7 S" B' k# W WScript.Quit();
+ z! \2 J4 d. Q0 P( P/ m7 W$ k } D4 B4 H2 }' m; T# M# |
} ) r" J/ I9 M( H
, P, l% q# [# b/ Ysimple.StartSimulation(".Models.Frame.EventController"); ! q1 ^, I1 E# X2 v) t+ c. K' Y
! \. g7 l% R+ ^9 d4 A9 G' L* X$ qif (simple.IsSimulationRunning()) 5 B# y/ M( _1 Y5 Y+ i
WScript.Echo("Simulation is running!");
$ G- F5 T+ L; A5 m; m6 z/ k . A% Q' [8 x* V; Z8 C* ]/ x1 h' Q
// Wait until simulation is finished 2 M( _# G3 k( i% Y }! u
while (!Finished) WScript.Sleep(2000); $ U2 |" S3 O8 }* [# M
% K9 Q) W8 w0 Lsimple.CloseModel(); 7 j4 t6 D' F: p
simple.Quit();
! I- s7 b+ z4 q, o* H- dWScript.Quit(); 5 x" I) N1 s- g! G+ |1 T. [& m
- y4 k- J; g6 z) ^- W) Z 2 m- R9 i9 ]1 A& y* \7 g
function RemoteControl_SimulationFinished() ( O3 S0 ~/ M( E3 D6 l. K# B
{ 3 l- D g5 c1 a
WScript.Echo("Simulation Finished!"); |