Example of a JScript 5 P9 C+ F, a% _' Y4 T0 v+ t
var vbOKCancel = 1; ( I. I, ?+ g* W7 X6 Y5 \
var vbCancel = 2;
2 ~6 S# J' ]0 x# E% z" evar vbInformation = 64;
8 D* k. x- O: b# D' e$ pvar Finished=false;
L# E8 `" k8 C# ]& H1 X" X3 j i- z# N6 G8 x. S
var WSHShell = new ActiveXObject("WScript.Shell"); ; u! f: {6 O8 j0 L* R
4 |0 Z4 \7 s! q7 ^) w* T
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); 5 C5 J4 n% [# r1 o1 D% w; t8 f: ?
; A3 i4 j7 y/ usimple.SetLicenseType("Runtime"); ) l+ J8 d' o5 s# U+ Q! b5 t G
. O& l" C0 X. t7 R/ L& v) |& [
try 9 a- q: v2 E( N& m; t F5 m( W. r
{
, X5 r# g8 |* p5 h3 v# A& P2 }7 U // Enter the path to a model file!
7 [* P" q! l, c. n: | simple.LoadModel("C:\\Models\\Test.spp"); . w e( |) ?" ~4 a2 x( Y' i" q
} + r7 {2 p$ X. H# k2 s4 A3 C: H
catch (e)
# ~, A$ `6 h0 b{
' |5 J4 t% B4 r5 s0 d9 V WScript.Echo("Could not load Model!"); 8 ?8 m! u1 k) X6 A" t) `- Y
WScript.Quit(); 8 T5 G" @% h5 o N' \7 F$ V
}
* i/ y) r/ O/ V2 J r4 u
5 o, V- b7 b* ?0 G2 atry
2 Z1 T2 H$ I& Y4 o{ % H% [! g/ q! `& Z
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
& `$ T/ s! Z5 d* L3 n: X7 G& r0 j r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); , L$ Y: h7 | w: y `" A
if (r == vbCancel) 7 g& x$ x; P5 s4 Z8 p' C
{ 1 ^: U- |. K& i+ K
simple.CloseModel();
b4 r4 x2 V( B8 b WScript.Quit(); 1 g% J+ K, W. j
}
6 y* l: B* g% {} 9 ?7 l9 N* \) |: \8 |
. d, l+ T6 b1 u. Z6 Asimple.StartSimulation(".Models.Frame.EventController");
3 |. \: l% q9 O7 V
! h+ d8 x' d8 q- p3 k# u+ bif (simple.IsSimulationRunning())
! X0 s5 s7 {8 ]! N- [ WScript.Echo("Simulation is running!"); 5 y u' i/ \4 ^# x( y, }1 y
& Y' K0 J: b: V1 f S* K# i* b// Wait until simulation is finished 6 j$ w' ?! d8 g
while (!Finished) WScript.Sleep(2000);
^2 I$ n$ i `- \ ( @& j6 X4 N; y! _0 b0 z1 J
simple.CloseModel();
. }$ g, v) F" O) B3 ~% [simple.Quit(); $ h g) K- r+ e7 ?/ u
WScript.Quit();
- |% {) `' S+ i8 k " c+ z) D4 _ H
8 @7 B4 t0 F1 c' h' G/ }
function RemoteControl_SimulationFinished() ' v2 f$ ^" b$ j9 A. X: |
{ b# x* f4 D7 }: N2 V' D
WScript.Echo("Simulation Finished!"); |