Example of a JScript " k j, v% g% A) u3 N% d
var vbOKCancel = 1;
: f, L# ^# @( g1 |- x" E# f6 O9 jvar vbCancel = 2;
0 \- Y1 I6 M4 p1 Bvar vbInformation = 64; . Y6 ]' M9 H$ Y7 [
var Finished=false; 2 a- r [, v# ~
$ Y' e, w8 E: C) H8 N
var WSHShell = new ActiveXObject("WScript.Shell");
8 d' O& G6 G: i/ M S; x; H3 ` Z
8 I& S- i1 Q P- `6 P0 H& A7 ?var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); . Z# y2 o1 o$ ?0 }) c% x5 V' v9 e
9 m5 z3 H1 s: }" s* C. u
simple.SetLicenseType("Runtime"); 7 ]8 n% e7 F/ x$ ^: [
4 p* _8 x& ]4 }% G6 U+ f/ D2 e h
try
% i( v: @1 U& A: _$ q6 E4 o{
0 h5 d$ l: U3 M // Enter the path to a model file! ; ^9 y" \+ n) G* V ~1 G
simple.LoadModel("C:\\Models\\Test.spp");
, p0 @* p4 E& @0 N} 1 [5 g) |' @8 j* `
catch (e)
+ Y% O* G- m0 a{
8 ~+ k) r8 `9 U WScript.Echo("Could not load Model!");
( \! E% Y4 R" Q9 m WScript.Quit(); % r) p4 I' ]* I# d* F' l' L
} 7 l m* @2 Q: W! m. D+ [; y
7 Q; d3 }% n6 ?try 5 W }2 }$ P- h! u" ~' \& m4 t( w6 U
{ * G3 [6 W* P6 Y! A c3 M' E# P
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
2 [/ n M/ I5 h2 `+ n; R r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
( z& I2 J6 j0 j* N3 F# n+ L if (r == vbCancel) 4 R3 B O5 \1 e1 A
{ 1 C/ A4 o0 b, Q" J2 q
simple.CloseModel(); ) G5 m. W3 \" V7 q) X) {/ P
WScript.Quit();
& {; q9 m" q( V8 K }
% W+ a/ ?* v4 m! C}
. D) d0 t8 w% j6 P
8 X$ w; N7 z4 C+ M% Gsimple.StartSimulation(".Models.Frame.EventController"); " g9 p8 s/ I: K3 c, H1 a( M1 r
h4 D" A! T3 D. Kif (simple.IsSimulationRunning()) ' a$ F5 y6 h: A9 h# }6 }
WScript.Echo("Simulation is running!"); $ `6 Q- |1 ]$ w' P
2 w5 {6 q& s. o8 v- e- U# i$ O
// Wait until simulation is finished * N9 g8 `& t5 [( T% q' N
while (!Finished) WScript.Sleep(2000); $ X5 g% B; b1 S- D1 s' P
5 V. ?3 D* j5 `* {2 Y3 msimple.CloseModel(); / b2 i4 l1 O6 q' Z( K+ S
simple.Quit();
7 g0 x7 i; B- p6 sWScript.Quit();
' W) ~$ b4 k- O& [0 |$ C6 K. y ( p6 Z6 |2 j& o* T, ^" {8 `
+ A; L$ D& d( z" R* b @# [$ ^. ifunction RemoteControl_SimulationFinished()
8 v- t5 v! v y* {* T% p; E{ ) m1 D* q' Q) I. v9 v' i* o
WScript.Echo("Simulation Finished!"); |