Example of a JScript
) T8 }# K+ a7 G, s) R" Yvar vbOKCancel = 1;
' K/ a9 d1 w) E8 z2 j" M% gvar vbCancel = 2;
5 f& ?) N; N$ d5 D' evar vbInformation = 64;
p+ b' M0 Z: J" Kvar Finished=false;
' b! i9 S' I* Z. i$ j
- Q+ p Y- a' P* a* _var WSHShell = new ActiveXObject("WScript.Shell");
) u* e. Z3 ~* g' [ 4 C \% n" w- @* F1 s: o# t2 `
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
& y; e# o6 g. Y$ T" c) y
3 P# D) I$ O+ f n' Y+ Isimple.SetLicenseType("Runtime"); ; _0 K1 A; W2 O; [8 z- b
/ h1 J! y0 U& Ftry
& j6 P$ z6 B- V- Y! n ^) P' U{
! s' ^& t. d5 y4 O+ c // Enter the path to a model file! $ [/ F, t* c6 [
simple.LoadModel("C:\\Models\\Test.spp");
% s5 T3 ?9 w" D7 w3 b; P}
. R5 V9 E, I' S4 p6 A% b: m+ Gcatch (e) ' h8 w: r7 f/ ?2 i% J- ^8 q
{
3 w2 y- l' n, r4 W$ R4 u$ h WScript.Echo("Could not load Model!"); & r6 F! Z) J: P
WScript.Quit();
8 O, Q5 w# D; Z. V% F} ) H& d) e9 s6 @! f. u
0 W1 _: j0 @7 t: M( N/ P
try 3 I& a% ^7 S2 \: R, c* G
{ + e0 O! G2 }/ B0 |
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 9 p ]0 y; K2 e/ a, _: }) `
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
( N" L: m/ Z" z3 x! X _ if (r == vbCancel) - Q) z2 t! y5 ]5 c; t
{
5 ^* R. z* @5 f# D* B2 z2 N6 o( f$ f simple.CloseModel();
4 y9 E" n( n2 q# G WScript.Quit();
. f( B' u6 H+ y4 r7 j4 w( o2 g: ` }
" n8 ]( g `) E} 7 e, I$ b- u! c$ R5 u2 k( @
$ ^6 C$ k# ~8 z6 C
simple.StartSimulation(".Models.Frame.EventController"); : p1 a2 g* `/ K& {
. E! z# e1 g8 T- w/ s2 z/ p
if (simple.IsSimulationRunning())
) U9 Z0 o9 W8 t5 U9 f4 H5 F I WScript.Echo("Simulation is running!");
- ~0 w( i& G# E0 ^5 D
- q+ p& z9 h: J" q4 X// Wait until simulation is finished
5 f+ a8 H4 V+ V! v* M1 }& Uwhile (!Finished) WScript.Sleep(2000);
0 L0 [' I: H. w$ `5 w( N, N) J ) {' u) _- {9 K2 p. U
simple.CloseModel(); ( B: Z7 L6 w) y+ i3 f
simple.Quit();
4 a! H3 u2 l( A/ S0 f6 F* mWScript.Quit(); & O" }' e/ X) ~$ A$ ^- w
5 I* s+ T4 \8 D @3 Q
' U9 ?) k# S) t6 D2 cfunction RemoteControl_SimulationFinished() 9 p% H5 [, X. x+ v6 k* }
{ ( G# j/ Y; Z( |8 V) K# i
WScript.Echo("Simulation Finished!"); |