Example of a JScript
2 U9 r* a: f8 J/ t+ K) X8 cvar vbOKCancel = 1; ; v( H) R# B: h n) @
var vbCancel = 2; & \9 U4 ~+ N2 }) J
var vbInformation = 64;
1 y" b* P1 N* xvar Finished=false;
' P) P, P t. b1 W1 o % P+ t5 a! ~& k! i5 F- H
var WSHShell = new ActiveXObject("WScript.Shell"); , z- O) `. Q; j6 N' t
5 W7 b) g8 @3 E+ j; Yvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 2 Z; H9 ` [9 b$ P
; q. W! l7 q/ r$ ?4 }6 |$ q4 T+ @2 D
simple.SetLicenseType("Runtime");
8 d% M+ R, |5 N& ]: ^9 p
1 o: }: i+ q9 e, E5 k: btry
2 {6 S: ?* Y3 Q V, E{ + A3 v! X8 W/ {- i& @4 v
// Enter the path to a model file!
- _2 V: ?% D9 r7 N) i simple.LoadModel("C:\\Models\\Test.spp"); . V, V0 F% [3 H" \4 A( F
} ) J5 E5 y# x' l1 F" g
catch (e) & C) O# }) v/ ~ I' I2 t
{ * |9 c) t# F Y( D& {/ m: h
WScript.Echo("Could not load Model!");
8 j3 E7 a1 |* v6 q8 b" R WScript.Quit();
! A) I' Y. f; Q/ h} M- Y4 P. l F& E
0 o Q! o! W- V; w8 h4 ?. j8 _+ _
try 1 ]4 q K% k: b& i( |
{
$ W$ d1 \; r( r, s& d2 T/ _ simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { $ r8 P( f1 Q! E1 L/ C, T
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ( s- q. M* a1 S7 e5 Q
if (r == vbCancel)
. S6 }) g! Q$ ^1 x8 J* o9 g {
+ S. T, d' c6 ^( Y- `& Q2 d% r+ J simple.CloseModel();
9 w) r N, ~$ w5 [6 c' G WScript.Quit();
, @8 P" Z7 w7 U& Y8 L* W: h' d } / N& o4 T. Y7 @3 k1 u
} * `2 E, A5 ]& A
$ X+ V& V5 O1 f5 ^2 M4 ~) F3 Xsimple.StartSimulation(".Models.Frame.EventController");
' U! p0 n# r+ c" e ; U' B2 \" n$ u8 _
if (simple.IsSimulationRunning()) - ?# n9 G2 u" [/ P5 A3 ?. \
WScript.Echo("Simulation is running!");
p3 I3 q* v3 f, l. B2 d
- X: ]; q0 u& \$ {# ?. N" |// Wait until simulation is finished 2 Q" r2 r5 K( t1 o2 |2 U
while (!Finished) WScript.Sleep(2000);
& p4 J: U1 k. I4 U9 k; F9 s
3 g& J% q- i3 o& m7 R6 W* ~simple.CloseModel();
; O& h7 G7 J1 G" Fsimple.Quit();
& g0 q ^& k( Y- O/ S5 A5 ~WScript.Quit();
+ K( d0 k! ^3 p/ j% Q, z; }
* e! \* L g5 i1 w& r$ r# e( S # o: f* g2 }! `0 C! R; }
function RemoteControl_SimulationFinished()
9 p* D' {! Q) f2 i{
" f" m" Y3 U& v! c WScript.Echo("Simulation Finished!"); |