Example of a JScript 1 i8 l! j+ c; a+ g+ H8 x
var vbOKCancel = 1; 6 F# w6 v- I' z- z: j5 ?2 Z
var vbCancel = 2;
6 ?) g. x) F3 Mvar vbInformation = 64;
0 m2 r$ h$ W5 _# Evar Finished=false; ( _( w9 U# O, l2 M# ~
* U" x8 \+ `4 q8 x2 r8 w- K$ U
var WSHShell = new ActiveXObject("WScript.Shell");
# q8 |1 y" H* }0 K. q5 ^, G
0 n# ^. f& c' }( h, d! X: xvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); ' @+ K% K; N+ C& o- M6 s
8 g. K, z9 w& B* a6 zsimple.SetLicenseType("Runtime");
' x- v5 @7 L7 I% T& l( `8 ^
3 X/ ~# s4 Q3 x" U+ Htry * x3 m* @! z* [
{
. D# l% z, S/ \9 a2 u: U // Enter the path to a model file! # {+ o! k& g. [9 H, Z; s
simple.LoadModel("C:\\Models\\Test.spp"); / ^! V" X3 P8 V' \
} 7 N/ L) S, X" x" Z* N
catch (e) $ ?, C6 Z9 l& |$ G! Y: e& V! T
{
; B! f+ J* N, g$ P1 O WScript.Echo("Could not load Model!"); ; C0 e: j2 @+ t0 V: D/ g
WScript.Quit();
$ f8 T$ m+ f7 b- O; E}
/ ]+ g$ U$ a! b: O
4 k8 @9 ~/ t) z4 y6 L R& ~: n+ l8 Ntry
/ \6 L/ P. N- R% s9 H1 s' D! X5 K{
) W0 a8 C9 ^% m& N) s& y) J( @+ V simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { " Q; O4 @+ e4 b! a
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ' G( ]& e% a/ n1 _. f0 y! i- A
if (r == vbCancel)
( d( S$ l' ?+ K I) O0 | { 5 E+ N8 l% |& V7 @
simple.CloseModel(); . ?& O) m# C6 }/ C
WScript.Quit(); + g$ Y( B' |/ H0 y$ x5 n: P$ r
}
% ~ P6 N' s# J/ u: {" [}
p+ P3 D; u: ~1 o$ w4 j : A6 a* I$ v) j p$ g
simple.StartSimulation(".Models.Frame.EventController"); 0 R' G# _- [- J# i% r1 j' C
5 Z1 w* H; ?1 }7 C' g
if (simple.IsSimulationRunning()) : ]% p2 m; P0 x
WScript.Echo("Simulation is running!");
; u* k$ R0 n3 x6 {2 F% } 9 Y! A3 n+ _$ T8 N8 s% p; c
// Wait until simulation is finished
. g, Z6 m6 T+ ~) ]9 I, mwhile (!Finished) WScript.Sleep(2000);
8 C) S s; c, A; M8 m- C. ^ 5 G; C7 m# T2 M6 g: S- K, Q
simple.CloseModel();
7 j b' G/ }7 D# T5 ?simple.Quit();
# f- D7 o5 N& A, x' }WScript.Quit(); $ X) Z% y- K8 p% a- V
. k; B J% A) n& ^' a/ g$ n& Y; X
( y! V% k; W5 L. O ~2 R! Wfunction RemoteControl_SimulationFinished()
( a' a2 P `4 \: G0 J{
* {7 i! A3 I1 ?* s* R1 T$ I WScript.Echo("Simulation Finished!"); |