Example of a JScript
4 g, i5 o. @3 {9 F; E. I# {; Yvar vbOKCancel = 1;
5 X2 N& _8 m. E( v& D' d7 S) Y5 Fvar vbCancel = 2; , T) @5 N+ a# b/ f$ q e
var vbInformation = 64; 0 h1 u. J+ a) j3 Y h
var Finished=false;
7 K; o8 v: ~& r7 e6 }( D
+ F9 y. L/ l# [1 Y" h3 k$ V- a3 nvar WSHShell = new ActiveXObject("WScript.Shell"); $ K7 V9 M- a0 j& l& C) E9 n
3 V% r2 @8 I+ j. `& bvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); , k1 w: [# ~" Z! C: N3 S
- d% }9 d8 e. U( d( qsimple.SetLicenseType("Runtime"); + A" ~- ?. |" e8 m+ a
4 O4 [ I- T2 P3 Ftry
& N- N# V2 U3 V! v8 m/ ^{
9 j; n) H; x+ l6 E6 {/ I$ I // Enter the path to a model file!
$ |3 b- Q, m A* w+ u0 M simple.LoadModel("C:\\Models\\Test.spp");
6 O/ ?! [, J8 f/ T: @: @} * D P+ G. ?2 N9 G( F
catch (e)
( h( t& w: }# E X7 W{
T9 ]. Y) t( U4 m% ` WScript.Echo("Could not load Model!"); . J( d+ b9 C- y/ |: h U, N" b
WScript.Quit();
# I" ]. P; m$ @* Z! F8 t7 ^}
' u0 Q+ F$ _9 g3 } + @5 G n" Z; T7 o5 M5 ~
try
6 J3 @5 n! P( x3 u# e{ % w9 i3 E/ Z. t Z; K: \
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 4 w0 Z4 [1 I/ O K
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ! ~1 x' ?9 G3 l
if (r == vbCancel)
+ [( Y* O6 v$ Q2 A { ) Q. Y4 V6 J; ^' t, o
simple.CloseModel();
2 h8 g, n: `) I7 y& R3 K6 J WScript.Quit(); " @: b! Q e3 L3 F0 D
} ' q) \. q7 e- _2 F. c6 R; N
}
7 B2 I8 L, ]. C& o2 Z' D, U
, A+ w' [* T; vsimple.StartSimulation(".Models.Frame.EventController"); . J& B& |+ y9 B% N. }+ B
5 a& }7 ]( `! w% \, @9 Z' _% Q4 Z
if (simple.IsSimulationRunning()) 5 r j7 Q( R3 c: x/ A
WScript.Echo("Simulation is running!");
" t' D8 L; Z/ `. Z, u
6 Z$ q0 b( |3 q// Wait until simulation is finished
- V/ d. B1 P9 p7 }! fwhile (!Finished) WScript.Sleep(2000); ) V+ V' ]/ N) x- x8 n, N8 U" O
' J8 }/ O6 M+ O3 b9 {, L/ o" ysimple.CloseModel(); ' d$ g' q0 c# P" V) n0 {
simple.Quit(); 9 R, J1 {1 H E8 e, R0 `: u
WScript.Quit();
/ p+ X% y8 _' c: ?1 D$ g
- {! j& @3 t v# V9 a0 ~
1 L u% h9 P0 u- \function RemoteControl_SimulationFinished() " P: b. u |6 P* H( `% Y/ ~/ ]
{ & d* s5 Y* m6 ?6 K/ l
WScript.Echo("Simulation Finished!"); |