Example of a JScript 1 y: _# [% `" ~
var vbOKCancel = 1; ! s, c& m$ p- y8 r* ~( o
var vbCancel = 2;
( a2 W% b7 P6 k. h4 I9 Yvar vbInformation = 64;
4 v9 m1 F: L A5 O3 O% D5 tvar Finished=false;
* r; g' Q+ q; M! \9 P
& J4 M7 b8 {/ ?$ W6 \) E5 Evar WSHShell = new ActiveXObject("WScript.Shell");
% R& j6 @8 }' K% X ^. b- Z
0 U0 v9 W; A) Kvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
5 b2 G8 O) d6 L0 b0 U1 I A' K
/ x& V- M" Z3 Csimple.SetLicenseType("Runtime"); 0 W& c$ e) b- ^" y
! D% n [ \* a% C
try 3 x4 I, g3 j. N3 t* w
{
) _. ^, ~+ M6 d1 J4 k // Enter the path to a model file! ) d8 T2 o# U* I
simple.LoadModel("C:\\Models\\Test.spp");
- |7 J2 m% ~2 d6 p3 d- \- x% h} 5 v+ I8 a' }+ [1 K- U
catch (e)
% X* u- _# ^ l6 g. c/ m; o{
: v7 E- a' O# }$ _ WScript.Echo("Could not load Model!"); * {$ {9 G* A/ K2 q9 s2 _( \4 ^9 T
WScript.Quit(); $ l; c# w6 B5 v; ]: p V/ W! a
}
( z! H) p1 u- K9 _! {* D5 S6 m6 S
3 q. u2 [! C R4 l+ ttry # n( m1 t! i" i2 V6 g1 j
{
7 c7 {% E `- G* Z$ p0 C& b simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { * K+ }& M2 s, k6 N
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); ' H O( [8 C) h" b e
if (r == vbCancel) ( M% C8 g* r( `+ ^9 c
{ 3 N( i; T8 q/ @1 @% P
simple.CloseModel();
6 `0 D. `- A8 X+ ~6 Z* e7 N/ @ WScript.Quit();
5 D1 _& I, B8 \9 Z } + H& c8 s& U" s/ ~3 N% D! s7 `
} 5 [3 p* e7 Y/ h1 Y7 w2 ]
" B4 G1 p( R4 g% I; h
simple.StartSimulation(".Models.Frame.EventController"); % u& p7 A/ M' u$ B5 }! d' T
+ n; `) Q' o2 s" Z
if (simple.IsSimulationRunning())
; x7 F+ R! ]9 @1 |( ~ WScript.Echo("Simulation is running!"); 8 K9 @* W0 l; J x A
' O9 D9 H0 u! ?% t3 Q// Wait until simulation is finished & v. K* s, a- a( g4 P
while (!Finished) WScript.Sleep(2000);
1 O G% U" [- {" }
' ]5 D9 O3 m6 m3 Gsimple.CloseModel();
" @, `1 X* p# X% F9 D4 Xsimple.Quit();
9 N% J) U: Q6 m+ c0 _ kWScript.Quit();
0 ?, l# l" p1 L# o# U' e
6 t# m) t p$ x; g. {* o
+ N3 G1 C5 M1 G9 cfunction RemoteControl_SimulationFinished() ) U1 I; F9 D" t' T: v
{
+ d, e1 s3 u- n' C& I WScript.Echo("Simulation Finished!"); |