Example of a JScript T2 D B: t% j" A/ s9 N
var vbOKCancel = 1; ) c# f X4 m* V4 f( s5 w( @& `( _! ]
var vbCancel = 2;
; L$ n J- y, Q" wvar vbInformation = 64;
- s+ X, l3 c+ i( wvar Finished=false; / {8 Z0 r7 n9 [& s. K
$ e% R- R9 U% E' f
var WSHShell = new ActiveXObject("WScript.Shell");
, L1 G) r$ \% h% E' T& X0 Y* n ( M6 [' U( j- W+ A
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
Q) |0 k( X- a/ ?. V & R. k+ O5 I( ]9 F, m# @
simple.SetLicenseType("Runtime");
8 k, I) _" f8 R8 R
. [1 _. y# h; l% O4 c7 Ptry " n5 s# N8 O6 M p2 G8 h
{
7 n$ U7 Q. q: e4 K // Enter the path to a model file! & B" n. f9 T; k7 u& ]
simple.LoadModel("C:\\Models\\Test.spp"); 6 g" T/ R0 d0 ^) k/ K$ C- P+ }) f
} * s: P6 C5 B1 Y* d" y
catch (e) : J$ G- h8 {8 Q+ V1 z) e
{
, q9 M$ \4 A3 _9 x0 G$ T6 X: d WScript.Echo("Could not load Model!"); 0 h6 X! w* X. R- p
WScript.Quit(); A( Z. g% U& L6 p
} * W+ w2 H* W! `6 i6 L- l
9 I7 J% e" r' k8 J) E
try 2 m {+ E" B6 M; b& R/ r7 g
{ 6 u4 V, h3 r' [2 n2 h
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
S- O8 V& y* x( d7 P5 U$ v r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 4 C5 \/ H4 g9 B6 Z( n( n# N' Q, U
if (r == vbCancel)
9 w/ a, Y c: G3 k { 5 l' |1 i( [0 I- ]/ T% K' Y
simple.CloseModel(); ; w' M n2 P2 K8 s$ s! }9 H1 ~
WScript.Quit();
6 x B; y3 `( d; I2 }+ D } 4 k, r& I$ C% t9 e) O5 k
}
9 _5 I" b% {7 z' d ( }9 z5 t, i2 H
simple.StartSimulation(".Models.Frame.EventController");
$ L! K. d) v7 P3 M
. r; |2 `+ w7 B9 Dif (simple.IsSimulationRunning())
$ Y N+ x1 `4 `* `( q WScript.Echo("Simulation is running!");
1 ^8 @5 `( _2 U4 B3 z4 p9 \
7 l7 o. O3 ]5 b6 I2 @// Wait until simulation is finished . t: H7 l9 o. x6 w
while (!Finished) WScript.Sleep(2000);
: ~ E2 G( z. [4 D) A4 H( w
% b; O8 G" ]) Hsimple.CloseModel(); * P |% w" Y9 }
simple.Quit();
* ], f1 l, \3 A9 p4 k/ wWScript.Quit(); ! X/ k* x9 O8 P
0 j* x, B7 a% ^
# f% K2 N" [( Z/ @function RemoteControl_SimulationFinished()
l, f7 d9 L/ V+ ?9 N! a{ 1 l' H/ ?7 u* y
WScript.Echo("Simulation Finished!"); |