Example of a JScript
) E: K( h4 N' d4 Cvar vbOKCancel = 1; % H) n" Q; ^; D: F
var vbCancel = 2;
, I! z. x, b6 i# J& b* p& evar vbInformation = 64; 7 J& b6 a. o3 F9 A# x
var Finished=false;
$ u9 j- Q7 |5 O1 ?: |' ?
7 [0 E3 s* h6 w* e/ b6 dvar WSHShell = new ActiveXObject("WScript.Shell"); ! B' ~! G9 f Y( J
6 ~; P; x$ M% K5 H8 `& N
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); % f& q1 m. b! z. A
4 k) C. U Z& g+ z! v
simple.SetLicenseType("Runtime"); $ j! y- c5 L! l+ \
- K6 ^; T* m- Htry / w3 @& o: }; |* f+ o
{
t, d0 }( V1 y9 n // Enter the path to a model file!
5 `" C; B/ b( m2 K! m9 O simple.LoadModel("C:\\Models\\Test.spp"); * B7 C) z/ x' p! E
}
# s$ Y5 t# Z3 n# p D6 C6 Scatch (e)
$ b( u$ C/ c3 }2 q4 J$ R6 g{
0 O0 p# g8 P, W# h2 x) @ WScript.Echo("Could not load Model!"); : V$ e g: Y" }
WScript.Quit(); . \2 d5 ~. l5 F( s+ a' t
}
# O0 S" p# H6 E( m! |- k
7 B( `3 V) u$ Mtry / J+ t: y6 k2 Q
{ / G* s8 G2 U z: V. c, i
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
! j0 _* w% c: G; w% o2 q r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
; x" l! L3 t s! A. O6 m if (r == vbCancel) " |/ ^$ @2 f5 V7 J8 g
{ $ } h- g0 I( |
simple.CloseModel(); j# ~. L- e* J/ R' y
WScript.Quit();
7 w. t4 O# [/ C7 h } + j, S7 }# d5 k
}
# v5 F, [' [- O8 N
8 P; R- j9 _+ A5 U$ C0 hsimple.StartSimulation(".Models.Frame.EventController");
& B6 ~ d' v. J$ H
/ J1 O8 I9 D2 w6 x! b& a7 ~6 l9 lif (simple.IsSimulationRunning()) # n2 c k# W! ?
WScript.Echo("Simulation is running!"); 9 B; A. }: G+ U, r
5 n& Y' Y, _/ w3 T7 F9 s// Wait until simulation is finished
1 G& g3 i+ q: ^6 @5 Twhile (!Finished) WScript.Sleep(2000);
# u4 x' A2 G) E3 W5 | f ' {7 L+ v9 L/ ? o4 k
simple.CloseModel(); 0 K/ i2 k: t: Y( i2 F; I
simple.Quit();
5 `) Z6 W. ~% o3 D- h( b) d. NWScript.Quit();
1 G, M3 t- F K/ Y* i ]
`1 }3 e5 ~4 x5 {5 w e
& H v7 [/ m" [: d K3 b8 [! gfunction RemoteControl_SimulationFinished() 0 i6 E U6 c7 {1 }+ m
{
5 L2 B6 U2 M( y7 d" J4 D1 O9 | WScript.Echo("Simulation Finished!"); |