Example of a JScript
) \, ^# R( b& x+ U1 c/ cvar vbOKCancel = 1; $ K+ Y& W3 M, S% J3 [ T6 e* }" K
var vbCancel = 2;
2 n6 T# A% G; C; V. Zvar vbInformation = 64; * q3 f( P# K* }1 R
var Finished=false; 2 q3 m( Q: \- M5 z% E7 y( j5 G
1 h- L% y: _, |
var WSHShell = new ActiveXObject("WScript.Shell");
! P) |. E$ K( {6 K2 G) Y# m . W V! m8 o+ A) k2 u$ h3 L+ ^
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
5 g2 C" i# j1 ?4 Y
1 o+ v5 m% ?/ ?2 X: [simple.SetLicenseType("Runtime"); 9 r$ F+ A% \: w" j c R. m, D2 W
+ N. B; G. o6 [! j- H6 A3 Z
try
2 U! j$ b) \1 F+ S* a* c0 M4 w; e! |{ - ?" N& v3 o4 u, v, i
// Enter the path to a model file! 9 G' N; |/ i7 S+ u
simple.LoadModel("C:\\Models\\Test.spp");
; ]+ f( g+ t. }* B3 W# t) r} ; ^* B* c* ?4 h$ ?, L
catch (e) 6 _8 [! Z" `' |8 ~+ |# F( v
{ 6 b, R. i% i- y7 C7 v
WScript.Echo("Could not load Model!"); 0 F9 U8 P6 ^7 U0 _
WScript.Quit(); : C; M: o8 c( _0 ?0 Y
}
0 o O( s* g. Q0 J2 I U
6 t. K0 Q$ L1 O0 @; E4 atry 3 L2 q6 U) i4 M; ^+ ^2 F
{ . ^2 ^8 V: g2 f9 p3 n- K' a3 r
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { Y/ C4 S' l: d7 R4 [5 w3 p
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
, j( j; n/ R, e+ s if (r == vbCancel) 8 W" ]$ h6 y+ k1 ] [8 D
{
R2 o* m" ?0 q) n9 W simple.CloseModel(); 4 ~( a; T# h6 V- P3 x) f3 G
WScript.Quit(); - ~1 |. G& P. Q" H/ \/ M
} ' ] U. d# l9 ^( t- b
}
4 N b/ ]3 W4 E9 V1 {) ?3 S + [4 Y2 m9 P( c) Q9 j
simple.StartSimulation(".Models.Frame.EventController"); . I+ w9 K4 y! g. |
: J. w. d) R4 G' d( B6 E# [ Rif (simple.IsSimulationRunning())
5 r- ]4 Y# R8 Z$ I- } WScript.Echo("Simulation is running!");
/ t5 g, P4 }! |1 f# M& E, O % t: \2 e! n/ _: _' s
// Wait until simulation is finished
. h* Y3 G# K {' B. Jwhile (!Finished) WScript.Sleep(2000);
# i8 T7 S# Z: G* |$ C1 `' B
' ]/ Y6 O7 U+ W' usimple.CloseModel(); 6 O" \# `0 f! Q, Q) ]' e, q1 E
simple.Quit(); ' C, E$ z) b% J, w6 @" {
WScript.Quit();
6 e3 U7 J9 D8 @9 f% i8 g) E
7 G3 w& Y3 Q+ J1 i
6 u5 n+ v4 Y8 F f- _5 xfunction RemoteControl_SimulationFinished()
1 U3 W+ v' Q+ m4 c8 D6 O" `1 N{ 6 P7 k/ `4 g! a1 G) Q
WScript.Echo("Simulation Finished!"); |