Example of a JScript # W3 e" t" @% L* r
var vbOKCancel = 1; # {6 b$ X" j$ J) Q
var vbCancel = 2;
2 N3 T* {, s9 h' l! Nvar vbInformation = 64; $ A u& Q0 P( j5 @$ O' H. R
var Finished=false;
, s% X. m# r: c; t ) ~' x! J: Y7 {0 H/ _) Z5 ]& W
var WSHShell = new ActiveXObject("WScript.Shell");
) Y0 x1 {- I! |5 S3 Z3 d5 ?' T
, ]; L2 b6 r! v6 J0 F5 ]var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); . A1 _) z# ], I: b
/ V% ^. \- H, [9 j' Xsimple.SetLicenseType("Runtime");
8 I' \+ X) S- F* a' a* S5 V* s2 A, j ' k; s+ |) J; O8 w1 P* [- X
try
. v; ?0 ^4 Y3 k4 U{ 5 W- C( j4 H" O, z6 @/ l' J) v
// Enter the path to a model file!
1 m/ W8 X, T* s! Z9 b simple.LoadModel("C:\\Models\\Test.spp"); 4 c6 ^7 O; w$ g( x9 M
} " T9 g! A( W' ]$ j v
catch (e) % v. E5 ?$ R% |0 H
{
6 T8 L$ v! I! i9 l- b WScript.Echo("Could not load Model!");
8 f' z# ~+ A6 ~' _ WScript.Quit(); , K2 a; N' q8 N% l& m
}
, s# N* y( u# Z+ f
* \' o) O$ m, Ntry 7 C" d3 m: Y. x; i" ^7 S
{ 1 @1 _0 D6 U+ _1 M6 Y0 o @( P
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
' W2 l6 A7 |! l/ S) N r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); & R7 A* }! a- B3 S. @& ]* w, K
if (r == vbCancel) + s" T7 k+ A) y! {
{ % Y6 @. s" b- k# ^( A) Y$ v2 F
simple.CloseModel();
?; e0 Q( Y5 h# b" J/ a! W WScript.Quit(); ! [( c6 U. W9 U' Z, T
}
1 p7 |1 C2 x3 t. u}
7 i1 g! M i2 R* f4 C
1 ]& t) @* |6 [simple.StartSimulation(".Models.Frame.EventController");
( T( U% Y1 F6 b0 f 6 Q6 F7 c" R( L% Q8 f A
if (simple.IsSimulationRunning())
7 V- g9 n2 ]+ Q/ y3 V, W WScript.Echo("Simulation is running!"); / u3 D7 G* L6 i7 h1 r" Y3 |8 P% b
* f, p' y* E) y: ?
// Wait until simulation is finished
5 Z8 k( e# B$ _) t% x S7 E, N1 mwhile (!Finished) WScript.Sleep(2000); ; H- e V5 R, I0 U
3 q+ D" N' I0 Y; E# C! |0 @* \
simple.CloseModel();
2 ]7 c- b8 d4 U) _simple.Quit(); * B7 @; l* g( D5 a0 g
WScript.Quit(); # H l- n) t- v' i% O& x
$ w( g% ]# X' a+ ?6 K + ^4 j- J% ^ q; c' u; A
function RemoteControl_SimulationFinished() ! N6 @2 ~: Z; ?( c8 R6 p0 ^7 Y& ^/ V
{
* l! ]9 V7 p9 }5 n WScript.Echo("Simulation Finished!"); |