Example of a JScript " T9 o, a5 E, Z7 @- L9 w
var vbOKCancel = 1; . {6 a7 M1 u1 U2 j
var vbCancel = 2;
# ~/ K( P6 {" X' D0 bvar vbInformation = 64;
/ \' G$ o; L$ P+ W7 Xvar Finished=false;
% \+ a/ M4 i; h( B% F0 S ; Q; c7 @, X$ u9 ~
var WSHShell = new ActiveXObject("WScript.Shell");
* j, Y6 V+ [: C3 |1 z5 c& ? " d: H* w, B# A' A" `2 s' X
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
* b1 d0 T3 [) q( K" `% A , h* m* C0 G0 L7 g1 S! f0 n6 Q( K
simple.SetLicenseType("Runtime"); % |8 p, p! A/ A; e0 M$ h: s! y: g
" Y# M% s# P6 ` V' X! A3 Q8 f4 ytry / i. _4 x& ~ }1 `$ W& @/ @% q
{
5 T1 ?6 I4 Q+ {# U! J" F // Enter the path to a model file!
! i C! j" ?8 q simple.LoadModel("C:\\Models\\Test.spp"); ! Z" P4 j! ~9 `1 z" q* h
} ! N' x4 J; j( v& h1 B ^7 c" z
catch (e) - s4 C' G& w( @0 F2 X% r5 K
{ s: s2 O9 n M& v1 Q* c; b
WScript.Echo("Could not load Model!"); 1 F% g- H- I. ]+ G+ b
WScript.Quit(); 1 F& [6 L# h, {: g; _# S% M
} / S5 M+ `6 }) a
1 d* {1 M" b& Q2 }try # a! M- j! h5 | o; h( t
{ 5 D. E1 [/ {3 E- a+ i
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
; X6 O F# I$ ~ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 4 D9 y$ a; p' M6 ]7 |6 b8 H* l
if (r == vbCancel) & h; I% C, ?7 [! {- Z9 F
{
2 D6 h% p% K" F: L; \: P( B simple.CloseModel(); 8 N- R- P) J3 @, m% H; q* P4 `
WScript.Quit();
+ p1 q* Z$ M7 a6 r. f }
/ R0 c. V/ h9 V1 n9 S4 f}
4 k* H3 {" j2 b/ Y
; _) S8 A3 ^/ S5 L2 Osimple.StartSimulation(".Models.Frame.EventController");
9 M& i! A j ? " L3 u( E2 h4 _
if (simple.IsSimulationRunning())
0 Z: ^: n% M) W m0 N WScript.Echo("Simulation is running!");
" x$ y9 D3 a5 V7 [% m6 ` 3 w, ^- h- y$ M i
// Wait until simulation is finished
: L. s7 t& _; \: m' |while (!Finished) WScript.Sleep(2000);
$ O7 Y/ D6 Z7 m5 P2 l 7 S. e$ J/ o( c" ~" h
simple.CloseModel();
/ @" e+ s3 A, r: ^5 bsimple.Quit();
% C. l1 Z K7 G" I- Q. B. fWScript.Quit(); 7 X+ D+ ^3 C! n, W
7 `# d. t4 s; W( x1 F5 x1 c! _ ( R, t" X* E- C2 x
function RemoteControl_SimulationFinished() + Q8 Y; `3 m" F% U5 c
{ 6 t5 y2 \" T7 f
WScript.Echo("Simulation Finished!"); |