Example of a JScript 5 Y/ Y$ l7 M# a2 T0 M) b5 U
var vbOKCancel = 1;
+ _& @# q7 F* l) dvar vbCancel = 2;
3 K5 n* X* C3 N F! T9 Y! Xvar vbInformation = 64; $ f0 H( _1 n& ]
var Finished=false;
5 z" J1 u& g9 \' T2 i% Q, ? % A$ k( }- }9 F/ h
var WSHShell = new ActiveXObject("WScript.Shell");
% ^+ q. c2 v2 W+ m; F3 O% M* h
5 V9 i6 T; `: C ^" Ovar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); & b" N6 x& ], ?5 s( ?
( e% t- ^, ]7 {! K* n
simple.SetLicenseType("Runtime"); 1 y% a2 Z- I5 Y7 r" }8 T% v
n/ W. `2 Y3 l! [3 j4 b
try : W# [2 t; _ J/ ~+ |
{
% Z$ j/ b+ u P6 L/ i5 @ // Enter the path to a model file! # ~: \' P0 l7 j, |& ^- V
simple.LoadModel("C:\\Models\\Test.spp");
4 f* w, e$ O; a4 w$ K}
% b1 W9 W6 _- o) q; }" bcatch (e) * R6 _, ?$ N) [
{ 2 a7 Q( P( \; j" u0 [7 O* _
WScript.Echo("Could not load Model!");
( ^* |- b. z6 M$ p2 Z- a/ Z; E WScript.Quit();
0 C' q) c8 G6 h- h. H4 u} ( ^! g# i( y$ x' V5 x2 _. Q
' @$ n5 U* V$ B: @# Gtry 3 N7 t0 h+ O. M" a
{ 8 G9 M) \0 c; q
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { $ {. X/ B: `) ^6 w) ~+ `% X, l
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); + s9 ^$ R- s# ~1 ~7 d8 W3 {8 U; j
if (r == vbCancel)
6 s$ j' {! G d$ i1 r3 Z {
. C5 b! O- `+ o+ g simple.CloseModel(); " m# a& ^3 x6 Y
WScript.Quit();
9 v0 p, _, u( H$ C5 x. V } 5 U" x% r4 `5 f& _6 I6 x
} ! V$ a+ Q1 ~0 e$ p1 P" U( M
& I5 x) [: w* `2 r, }2 G" B
simple.StartSimulation(".Models.Frame.EventController"); / `! {, @/ b2 L/ S. a3 H1 P
) ^, G: g7 c9 Y
if (simple.IsSimulationRunning()) / `" A. b' h/ E9 F
WScript.Echo("Simulation is running!"); ) ^. D& J) m1 m# s: |3 s
+ {6 S: T9 g2 D) W
// Wait until simulation is finished
" g8 Z' |+ u4 a# b9 h8 I6 c9 U xwhile (!Finished) WScript.Sleep(2000);
' O+ x& i7 h/ ?* A$ q* u6 E ) V! |& U$ h# b4 |, {
simple.CloseModel(); 8 N( E$ o5 W9 z4 `& e1 z* i' D
simple.Quit();
M! ~9 U0 d4 d( I8 EWScript.Quit(); - l# o8 C; \2 W' _! X8 y$ Y
7 r7 U! e, i3 o# L: t/ _/ i
' O$ R: X& l5 d: |! b ^$ L6 R
function RemoteControl_SimulationFinished() & C, B( f. J1 g, [2 _7 j
{
4 z! ?5 i4 q i* V, t, | WScript.Echo("Simulation Finished!"); |