Example of a JScript 2 l" w" t: ]/ u9 B# b
var vbOKCancel = 1;
0 B/ E. ^9 t; P9 Nvar vbCancel = 2;
. Q% c4 L" B7 n, L2 z1 d- v% Zvar vbInformation = 64; 5 q. [# t2 I! C$ U
var Finished=false; * s6 \4 J* R+ o9 c* m
$ \4 d6 k5 Q5 K
var WSHShell = new ActiveXObject("WScript.Shell"); ! v% k1 [- i# O/ b3 S! W
w3 E* ^- X0 `( w0 wvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); " F+ t8 a7 ~8 M; W+ C( V* }
1 D) Q! c0 B. m q, z
simple.SetLicenseType("Runtime"); 8 \$ J8 m, U$ }% ~$ Z* C
4 w4 ^5 N8 s$ J) ttry
5 u8 p( c+ d: \4 m{ 7 a- K. S3 H: u5 h2 ~
// Enter the path to a model file! " Q% p# C- }4 |
simple.LoadModel("C:\\Models\\Test.spp");
: a% u+ J- N4 R/ ~ J} + s* x* f3 w$ [# A. L) P
catch (e)
4 M; q3 k) N. \, r! G' z{
! f7 n' V9 r9 |+ G WScript.Echo("Could not load Model!");
# B2 P7 y2 X! B9 |% p' y6 u WScript.Quit();
/ w* x" j7 A% R$ M! g}
5 Q6 B2 M! l/ h4 H# C, i: Y7 H$ a
3 \1 E5 a: ~- K5 J- Htry 5 L T4 q2 P! h0 h) d
{
" _- ?: ^: @8 W- ? simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ! @. V3 o; H0 n7 f" J4 ?
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
+ \) k4 I0 F" d* P if (r == vbCancel)
( L: b. J. F1 V* s% P6 g {
( ]6 \8 G$ V" y( \ simple.CloseModel();
; M* b. l, ?! H WScript.Quit(); / j4 z k) x; @5 _8 ]8 P
}
7 q) {" e7 a5 p1 ?; ^}
y+ w3 z' L( X4 B$ n1 u A) b: L
; l- |8 I! h7 R9 Zsimple.StartSimulation(".Models.Frame.EventController");
2 |/ G6 \8 P5 c; T% Y/ [8 | s
+ _5 }; @' m X" yif (simple.IsSimulationRunning())
2 H: `* N+ O- z' i9 g WScript.Echo("Simulation is running!"); 3 _+ q4 W) S# x( H) `
/ Q5 B- Q% O5 w7 I// Wait until simulation is finished * @( W7 H9 \" w
while (!Finished) WScript.Sleep(2000);
9 {% t8 k2 H) R: T2 d3 M6 Z! `: E
7 C' O/ N/ k& z( ^simple.CloseModel();
( T( t# }& c- a' Q- ^& Tsimple.Quit();
$ _, C, C& B7 V9 L1 DWScript.Quit();
* L, ]2 f, M- x6 V 5 U3 E3 H9 z- D
4 X. N; x6 [, P# L1 |! ]/ |
function RemoteControl_SimulationFinished() 0 t* O' F6 R. R+ K9 W' N1 N
{ 3 c) Y9 Z) A; m J
WScript.Echo("Simulation Finished!"); |