Example of a JScript
5 ~' a2 u+ e1 d C8 _( _; j3 vvar vbOKCancel = 1;
' s# _" |# ]: xvar vbCancel = 2; & D. M) H; J1 H5 s2 I
var vbInformation = 64;
3 q( t; b' j6 h' q- Z3 {var Finished=false;
- k1 m) \$ Y7 j2 Y
2 F. B% P, z' x9 A( ^var WSHShell = new ActiveXObject("WScript.Shell"); : e: R' Z$ F) R) l
, U+ a3 z% X6 M+ f9 k1 Evar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
' m- {. _0 N8 w$ F1 ?
; M, `4 S# y/ O) nsimple.SetLicenseType("Runtime"); , P) `0 q \% F- I4 {
1 `' p/ o7 h$ {8 r4 N- T, S7 U
try & v" X: v4 A" K- H
{ + m3 b) E% S! B/ U2 u
// Enter the path to a model file! * @5 r$ z& Q" F' f0 v4 V- Q
simple.LoadModel("C:\\Models\\Test.spp"); 5 z3 e4 g: h9 w, k" n$ ^
} : R* u$ y# t5 ?! c9 n) a5 Y; k8 a
catch (e) - z2 r& L+ \4 e8 |7 x+ {
{
( @" G$ v2 C8 t# f0 r: b3 P WScript.Echo("Could not load Model!");
+ x" r# E* k! q0 d WScript.Quit(); ; d: {8 p0 f/ K# B: w
}
- p$ X: T" k7 t5 |
' y0 P7 ~4 c0 g9 b {8 a5 S% \try 4 G# n: ^2 D' _: [0 K. k
{ 4 T7 P+ o) p! ?- R
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
- c! z2 c2 T1 Z* V3 |8 ]) F: b r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
# k# ]* a# A- B+ O$ Q* W7 _ if (r == vbCancel) 3 y, a- ~; a. T8 X& C: M( @* A
{ 7 x/ G4 u1 z5 L: L# z
simple.CloseModel(); 3 |6 t+ K$ g6 }! A \- z9 k
WScript.Quit();
1 @9 j1 H9 y" P! Y- O' A }
% S" `/ A" s; E) T; m' i3 i} 8 Q) I0 K) q5 d8 Z( }+ n% b
5 f$ S; B' V1 t7 j$ G( W- I- z6 z# o
simple.StartSimulation(".Models.Frame.EventController"); 5 o( _5 w3 p: Z
- V4 e; y- A7 E7 c
if (simple.IsSimulationRunning())
! g/ D; r* E+ w3 ], P WScript.Echo("Simulation is running!");
1 U" ]8 U/ N6 {: h( A9 V 7 R) d0 Z. ^- W5 A' D1 x. H
// Wait until simulation is finished
/ Q9 ~& a7 G9 X) dwhile (!Finished) WScript.Sleep(2000); / P3 P* T7 p4 [. c) K
* s+ J7 z% H3 x; Isimple.CloseModel();
$ ^* ]- ^8 K. Y: c/ ]4 [- wsimple.Quit();
) d- s, w* {4 Z; P- PWScript.Quit();
: r4 |9 A+ }: F; V0 t - x) d# K1 B: a& C& u3 ?6 O6 ^
2 f q3 i: Z- c3 k \2 lfunction RemoteControl_SimulationFinished() 7 _5 T* p% s; l) W8 b" ^( T. K
{
* ?; `) V8 M$ V6 i9 K WScript.Echo("Simulation Finished!"); |