Example of a JScript
3 R# d4 n, ?" n3 ?) S" \8 Zvar vbOKCancel = 1; 3 N* Y5 O; g X' R9 j4 i+ h! F
var vbCancel = 2;
" g, u, T/ B/ j3 Cvar vbInformation = 64; ' W# { v! N, I. b: ]( N5 K$ O
var Finished=false;
. i& H# `. h( |
' O) C( V; k Jvar WSHShell = new ActiveXObject("WScript.Shell"); ! d7 u6 n0 I% d+ K& t1 ^8 ^" ?
' [. W# |* }$ g+ }" o+ n/ p' Uvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); " K$ u& u- e8 X- X# I' u( b% @% m# r
" K9 {8 S1 H$ z# ?' N1 d# q: v* csimple.SetLicenseType("Runtime");
& C3 P4 O; H$ y5 t: }
. T: s. h$ H! w9 Ytry 6 f; F4 @3 M9 _8 A) }
{ 3 q) v: S8 E9 v1 h# ^
// Enter the path to a model file!
, G& R* ]9 F2 {* F0 a! b simple.LoadModel("C:\\Models\\Test.spp"); 6 H# c& A- s: Q5 _2 \9 i, r. _1 P
} * t+ Q4 N, p- ?: z/ M& f7 ]7 }7 Z8 R" F
catch (e) $ E1 w+ x$ i: q+ p+ x
{
z$ T' G/ J( ]: O- K, K0 R WScript.Echo("Could not load Model!"); ; w* U5 k1 w2 f& }
WScript.Quit(); 2 @0 \! B: K4 p6 p- @
}
/ T% V- r! q) M9 e + v/ O8 E- R2 F1 ]; o; m" X6 G
try
; U: @* z# E/ W{ " }4 Y( g3 P- s
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ! X/ T/ Q ` G F! y
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 4 I) i2 w7 m3 L* w5 T/ D
if (r == vbCancel) 7 }$ e1 G& c; v5 c4 a M& G. j
{
+ C! }+ Y6 D3 n simple.CloseModel();
8 G3 `( E4 W5 |- H) E WScript.Quit(); : X/ s; X9 c' x( h
} 2 k' {/ M l5 c9 l) g; g
} # w L7 h8 j3 j" U) I
4 C) W8 h+ d5 t/ usimple.StartSimulation(".Models.Frame.EventController");
: _2 @1 B$ b% P4 S, v# m , J0 f1 E8 Y% O1 j
if (simple.IsSimulationRunning()) I3 z# N) ~0 q: z
WScript.Echo("Simulation is running!");
, [) Q5 `8 b1 T" S: }
' j9 s0 w! A+ j- u// Wait until simulation is finished - x3 C8 Z! |# d' d( }
while (!Finished) WScript.Sleep(2000);
4 _9 s4 Y/ |' @ & W6 a2 }' R8 q* L2 z
simple.CloseModel();
) R: h( G" z% Y* F' k/ h9 x' x1 gsimple.Quit();
2 {: ^/ g g+ _% H6 \WScript.Quit(); ! Q4 X7 j+ y- ]- T+ O& I# `
- E7 W# y5 @% p7 L( n' {8 T) A 9 `" I. `* {2 d2 @0 U
function RemoteControl_SimulationFinished()
5 ?! W$ v, E( p. j% m' h/ D) K4 |' R% }( @{
6 o$ K5 }" Y/ d7 C WScript.Echo("Simulation Finished!"); |