Example of a JScript 1 F; c2 Z1 N' [& u# Q
var vbOKCancel = 1;
4 q3 R5 R; B9 M/ Dvar vbCancel = 2; / @; ]6 C% C7 s* j7 |
var vbInformation = 64; * x# w* V/ d* x: n
var Finished=false;
8 k' Q# Y$ K7 K1 |! S0 }
1 L, c0 r u1 ~+ {var WSHShell = new ActiveXObject("WScript.Shell");
: q2 J( e' R& k9 e* ?2 N ' H( p( O. R! A) |" E4 L
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ( V0 T k0 Z2 s7 ]4 S. ]
8 E2 B/ y5 I( ?$ O0 W
simple.SetLicenseType("Runtime");
# E j0 Q) f; t# t* @) i$ r ( w! b% }3 }$ c3 s* }
try 5 w6 v0 f' G0 h8 P6 o1 n
{ 9 T! V8 S4 D+ Y: u2 T1 y
// Enter the path to a model file!
+ |! q( q& h" k' |( h, V% J" p simple.LoadModel("C:\\Models\\Test.spp");
& v5 D2 M! n% |- V! r}
' n) {9 }* T9 M9 M- j2 a+ pcatch (e)
( T/ K; M V2 g; g* `{ * }2 s) H5 _- T
WScript.Echo("Could not load Model!"); - R7 j! R6 g) M
WScript.Quit(); 6 r* u/ t. X9 S: \
} ) I5 ^4 y, G2 |& e2 \% h' \
' g# \. M! s- Ltry
2 N$ W% e6 n+ @' G+ _; g{
/ n0 y# Z$ l$ g8 o8 ?/ K2 M9 t- s simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
* d, p8 W( F: ?& y; { r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 6 e; T+ U+ P, [* n3 S$ n( L' t
if (r == vbCancel) 8 S7 z2 O+ ~; y$ F6 {$ J
{
2 {/ K* Z) t# j) x1 C+ A simple.CloseModel(); 3 J( p4 Q# T: h5 H5 I2 O
WScript.Quit(); - _' {6 [3 i; c- m
} 1 A: _& {% \+ `( P8 [( F
}
% K& A& ]& ^5 G) ]8 Z& ~ , S$ @4 u9 M& r- D
simple.StartSimulation(".Models.Frame.EventController");
4 B- V6 m. u0 K% r+ y
: Z) c9 p. P* I+ \+ b9 W) b: |, Gif (simple.IsSimulationRunning()) 3 J( \3 ?9 s' a1 ^9 `9 }# d1 ]
WScript.Echo("Simulation is running!");
9 t2 {1 k0 V+ I ! b4 b" \) u7 A
// Wait until simulation is finished ) c4 O _0 ?- v) L
while (!Finished) WScript.Sleep(2000); + z: e' a8 q, c7 n' u/ |" K ~$ a# y
/ n3 `' A6 a+ w- p' gsimple.CloseModel(); : S, U1 m; B8 d- m1 d
simple.Quit();
8 i4 o; K" i0 |WScript.Quit(); . z! W% E: A" ?$ V! ?9 I
4 q- b% v$ |. K( a3 m# H+ B! P4 M
/ F! J, H( C0 \2 A$ l& O) Q, ?1 Yfunction RemoteControl_SimulationFinished()
7 X% c4 `2 |0 m6 ~) ^{
$ w8 P/ ^! k- f: Z4 R WScript.Echo("Simulation Finished!"); |