Example of a JScript
# l! j3 l; e+ R0 ^var vbOKCancel = 1;
7 _; G5 i9 Z# o" X- w; S4 Rvar vbCancel = 2;
% X9 ]: R& B# i; v2 W& J* s% O& evar vbInformation = 64;
7 d% h$ ?- M. m+ w% M: Lvar Finished=false; 9 G9 W$ G: \' C6 S. ]
: U+ g$ w0 o7 w/ I% W6 `; @var WSHShell = new ActiveXObject("WScript.Shell");
" n. N& V4 U7 R
" \8 K1 m* i3 A' \var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
! \1 j5 X% w- i# {( A" J. U' c / D8 Y6 ~ i6 e6 y% s0 b. H
simple.SetLicenseType("Runtime"); 8 t% v( P. |; Q
0 a$ V& F) l) U! d
try ' @- U; L& L% J* T- F/ _1 r
{
4 |$ j4 ^0 Y& h: C& F2 P. s6 m* N // Enter the path to a model file! / Q# ~/ [' \# e# |+ d
simple.LoadModel("C:\\Models\\Test.spp");
3 o7 B. b$ k3 F. R} 2 s! q3 k$ t+ w, n! Z$ R
catch (e) 6 K- y! M2 q7 D6 x& b
{ , x; @; O) Z& `% W
WScript.Echo("Could not load Model!"); 1 y% @& S" N' d/ f7 J
WScript.Quit();
7 v1 {" p8 Z' r$ }0 a/ a+ O! x6 q& t4 C) P1 T}
& j* C, t" Q' s - U( U$ `$ [, x" o& K( i, i
try 4 y6 ]/ j9 O# U& F# g
{ , Y) f s: |" E8 R! V
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
/ z* W N: F7 w& O8 Y r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
7 j1 n5 N0 Q- j; S- T if (r == vbCancel) 9 |( Z2 w$ _: _2 b- o. X
{
$ u0 ]" s) h: S) k% w simple.CloseModel(); 0 E e1 d' u/ w! u
WScript.Quit(); & L" d+ P/ E6 A9 f% j
}
9 d* @3 ^0 \& Y% i1 o} 6 ?4 U4 I' t$ M4 B: L8 n
; W: E" x* Z5 V
simple.StartSimulation(".Models.Frame.EventController"); & [( H, {' D4 }7 |" p/ E% e4 F
" e' k# V6 J* S p. V" V- L+ ^6 Q9 nif (simple.IsSimulationRunning()) & |: e) s( H7 t$ u2 T
WScript.Echo("Simulation is running!");
( a+ [1 }( n# `4 ^4 ~" m* C ' V; T% h2 V0 n' d) F
// Wait until simulation is finished
9 H# _9 ^' B. [ o! _! ~while (!Finished) WScript.Sleep(2000); * y8 @$ ~9 N) c8 u2 l i
6 d+ y0 L) {) |) p# o; Z+ ?
simple.CloseModel();
$ b+ ?) Z: Z' x: asimple.Quit(); ' i. N( c1 k: z+ J8 x
WScript.Quit(); $ q2 i* \, U; @) Y9 t& C' V, U
8 Q' P2 l9 U8 e$ }
O, @4 ]% J8 P+ g7 wfunction RemoteControl_SimulationFinished()
9 `0 K- Z: n1 E) f5 y# }6 I{ : c: D. i9 }" x' M, a- v$ ^
WScript.Echo("Simulation Finished!"); |