Example of a JScript
$ w, E% l, S9 ~3 Avar vbOKCancel = 1;
; D- [2 l4 s, H* N* Evar vbCancel = 2; # n8 Q/ ~: Z% v0 M6 |2 w( L
var vbInformation = 64;
5 r0 t7 }7 R+ G! q% q- ivar Finished=false; - x4 k& |% ~# z
9 R" i7 G4 w2 F6 Q8 ?+ s( H9 ]
var WSHShell = new ActiveXObject("WScript.Shell"); 8 M* e3 @8 T( e* I3 L. M
7 c7 @* ]7 b& w; i! a0 A2 W c4 Y/ ivar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 0 c, t+ [/ U/ @/ [! Z: Q# `
" g4 ?0 s8 I: K% k
simple.SetLicenseType("Runtime");
; w1 t9 H; X/ j+ P, I$ y
2 C. [: x( J9 [2 ^1 _8 ?1 ptry
0 i- O: \) r1 E: l) }. q! n# f* Y{ / c, X9 w% a) @, l: `. G- J
// Enter the path to a model file!
. Q0 j+ j1 O3 R! v# Q+ O simple.LoadModel("C:\\Models\\Test.spp"); & y2 ^' g; W# M- J2 I) {0 {5 f
} : u& t8 T) ]4 O" L
catch (e)
' P0 t0 G0 l9 _8 z: Q$ y; t. D{
# Y2 @! }$ K: x WScript.Echo("Could not load Model!");
) ]7 N7 R- [- K( K4 F' j WScript.Quit(); - \* {* _# W0 a5 C
}
2 d7 O; e8 N2 M% `/ A
# H5 w" U9 m0 Q7 ]; X X# C$ {1 xtry ) U$ p+ ]" L& G' f
{ ( X1 p* e6 C. P4 ^- u5 z5 n8 g
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
7 F: @+ i) G% S r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); + p% {0 j) z) N Z3 b$ \
if (r == vbCancel) . a! m) Z: k7 A* B9 g/ f2 X, s$ l/ |
{
4 |* I% L6 c& {7 G0 E! \8 P simple.CloseModel(); 2 K% Y z/ j1 A" l- o; U- @
WScript.Quit(); . t! P+ j, }) A0 v4 R! K' _
} " n8 u7 i- @& r
}
3 B3 v- m- b6 |/ T/ C/ c " q" R) W* A: t) D) ^! l2 A' x
simple.StartSimulation(".Models.Frame.EventController"); ' U/ D- O) ?" ]% e, V4 r5 G
3 @7 ]4 L, l& X9 F; \
if (simple.IsSimulationRunning())
" N; b/ R) {9 D0 F* \+ M& h& E; U @ WScript.Echo("Simulation is running!"); & G" T/ X4 x0 [8 h8 l
' s# W2 _4 J ^. g, F; R: a// Wait until simulation is finished
; t( m. A7 ?+ H2 ^; v5 }4 ywhile (!Finished) WScript.Sleep(2000);
9 ^7 O. h1 _% m& u2 Q 4 ]7 p* \/ M7 `6 K" d0 L5 z3 Q
simple.CloseModel();
A4 O: x( n7 N' O% C1 Rsimple.Quit(); 3 v0 J2 `# G. p
WScript.Quit(); ' [/ I, a5 L4 b+ z% \' Q: l3 p) J, {
w/ H4 t. g( r* V, J+ u 1 ^* Q1 R" n4 c; Y8 e0 U
function RemoteControl_SimulationFinished() ) p' s8 g" L% M6 b
{ ' s* T2 b8 U- }! \3 ?2 S
WScript.Echo("Simulation Finished!"); |