Example of a JScript
7 C- _1 S F3 J, N( m& j6 [+ z6 O6 c+ pvar vbOKCancel = 1; 3 p5 d0 n# G( g: y5 r
var vbCancel = 2;
/ g* v) R- J3 x! j/ w9 z: c5 r7 Q% C: Y3 Dvar vbInformation = 64; & T0 \# N$ f* g4 l. o0 T" w) {
var Finished=false;
, P" z1 W; X" s6 P" [
# {: ?& B! x$ \4 tvar WSHShell = new ActiveXObject("WScript.Shell"); 6 H# k; ^" \% d
7 e' [7 ~3 ]( B" dvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); " @. q" j8 @2 V. T
' c% j7 A' {* e/ b+ Z( }/ ~; f& y- a
simple.SetLicenseType("Runtime");
. t1 x' n% D' @, u; W; L+ s+ I
3 P4 S, M6 | p& ~8 Q1 Q! Btry 8 ]0 x% O. ?. d, E2 K) z
{ $ C' M* W# f& U1 k8 \
// Enter the path to a model file! $ C$ k: A3 \8 ~! k' x2 c9 G3 |
simple.LoadModel("C:\\Models\\Test.spp");
4 q y+ ~. {# |. V' G/ e}
F, E: J% M. Y/ g7 g3 ?& }catch (e) 4 a9 v+ C7 W5 M- W1 [2 z0 n% B3 p
{
( H/ y% g1 |' t. y WScript.Echo("Could not load Model!");
# G) P3 ~( {/ O; u WScript.Quit();
1 P8 ] ^( R% Y# T- S4 I+ L} 1 n9 H7 T1 s) \! w. m8 g2 M
$ \1 c; K" O& t p# ~# d
try 1 \. T8 ?1 k: N- Y
{
% ~! }6 d- Q; t! k6 ]& ` simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { . T; ~% n _0 j! r6 H. D" e
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
8 ^- S3 }0 w$ |7 G if (r == vbCancel) ( v4 S% W3 q( {6 J" Q
{
4 u5 S% w; t( K simple.CloseModel();
$ A9 M( x3 ^/ l4 u: z% T! B' B WScript.Quit(); 3 {( K$ ~, |1 r4 f
}
1 l5 C& x- s, e8 E& I} U1 x7 b- \& Q# A; K+ \
- z2 |: R( ]' N. O( k2 a) b/ Q
simple.StartSimulation(".Models.Frame.EventController");
* }. ], Y3 J! t) k
, A5 Q5 ~0 ]. \6 D$ a) Dif (simple.IsSimulationRunning()) ! [5 v+ \( n# |2 d) q) w
WScript.Echo("Simulation is running!"); . R5 b( Y& r9 T/ e+ p
: \2 k4 S8 I6 B4 O" q# p
// Wait until simulation is finished / j0 t) ^" k' o2 I7 U8 G
while (!Finished) WScript.Sleep(2000);
x: H. [( M9 ]/ x 2 v' Z6 j% s3 q# c1 S" s
simple.CloseModel();
8 f) q" v q0 Q- L8 f0 C( ksimple.Quit();
2 `- x1 A/ U) N8 q9 TWScript.Quit();
3 P) |2 H! Z$ Q) W4 `: }- q) G* t 7 L6 W; Z: h& w0 J- X
$ m5 l0 r6 @& e) u8 p& r
function RemoteControl_SimulationFinished() 6 Z, X) r7 S& R0 `
{
( l: h& L8 n3 @4 ?4 S WScript.Echo("Simulation Finished!"); |