Example of a JScript
8 E( O( t# c, Y) t) {1 ?* fvar vbOKCancel = 1;
3 Z& w$ s+ g/ F7 o. a$ k5 b$ bvar vbCancel = 2;
' _* ^* ?6 Z# e4 [/ S" C. Wvar vbInformation = 64;
* F3 V. Z3 \. i& P6 E$ c* ]var Finished=false; 2 R9 b- B% r& `2 u2 `2 d
4 y, L5 S# x% d6 H
var WSHShell = new ActiveXObject("WScript.Shell");
7 a5 B Q; z7 X8 P7 M* S & W1 } J" I; c9 B
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
5 g' c- l: w3 i, x- u % p0 f2 w" p: R9 j$ n; I
simple.SetLicenseType("Runtime");
( Q8 z9 ~9 f. A! v 5 a' C* |6 O0 X: g2 c
try ' C0 s" C/ e' |: ?
{
6 f: Q8 L, U8 B% S // Enter the path to a model file!
! J, C# z% S. A3 l5 d1 M# P simple.LoadModel("C:\\Models\\Test.spp");
- S: \. ]8 T) W2 ~) R' B" x}
2 d+ D& S+ S) @8 Ocatch (e)
4 g$ h' I3 V& i0 i N6 f{ 5 f u# L, K. F3 S, L: }
WScript.Echo("Could not load Model!");
; p$ l8 J- l7 p2 C WScript.Quit();
: i( `5 I- s; @4 |1 B9 P}
; O( T( L2 Z( O
& [6 g! h/ j( R! x. |- U- E6 gtry 2 N) u! g! ?+ p! e
{
( T' f. b- w( Q2 T! x4 `- m simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
( @, q2 e0 n/ X$ z) {" v6 W3 L+ v& ] r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
( h2 j9 P& [: x; R( Y+ W4 Z if (r == vbCancel)
. ]8 ?( b0 m1 e8 \ { J- E$ V u% i9 N# h' r
simple.CloseModel(); * t. Q7 d+ Y; J& Z# j- G
WScript.Quit();
/ q }. i% j9 ^1 ~3 {" n } 7 w5 h8 r; Z+ w/ w, _+ E3 B
}
+ H" u# Z( A @ I; m4 c2 f6 A 2 N2 ?7 V+ [# ~9 B q B* U
simple.StartSimulation(".Models.Frame.EventController"); % u6 a+ Q+ T+ G ?
" x0 j b/ R6 P* ^# Qif (simple.IsSimulationRunning()) " S$ f2 j4 x$ _
WScript.Echo("Simulation is running!");
- e; s9 T8 h6 h; A# F % n6 d, x9 w4 A: u1 M" }7 f" {
// Wait until simulation is finished # d/ |9 P7 S' _/ v- S% c$ \
while (!Finished) WScript.Sleep(2000); ) U7 h' [% `, o4 h- k# s; b! T
0 O7 Y+ D- J3 j2 Y% ssimple.CloseModel();
! |2 d7 O8 ~3 E* ?1 v1 G( k! w' Zsimple.Quit();
* x$ x a' {6 n3 f( X- rWScript.Quit();
3 C6 A% }$ r6 k/ I8 R: j$ p
- Y( f I# i: \6 ~ z $ I. F8 }1 p! E/ H6 _; H! R0 v
function RemoteControl_SimulationFinished()
& v/ h, ?) _, E' R" @) r{ $ {, \3 r* z1 j6 {, N- s9 S
WScript.Echo("Simulation Finished!"); |