Example of a JScript 1 F6 g/ i6 S% a, |" X# r
var vbOKCancel = 1; ( c# Q- |' j b$ k( ]4 W. @
var vbCancel = 2;
, Q. O3 A6 ?# qvar vbInformation = 64; ) i/ H: H! i. l; [% f: X- q) y
var Finished=false;
3 p+ N; s ^+ }/ h " g+ Z: B% t1 m0 }: c! A; P4 p
var WSHShell = new ActiveXObject("WScript.Shell"); , V: @ b0 U( q# E" H6 L/ j) X% v
) A3 ]/ ]1 b# r) vvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); , A4 s; z3 h/ Z2 O# g! |
/ T2 o8 e; ]3 s7 ?% n/ z
simple.SetLicenseType("Runtime");
2 H U$ _2 r& I, U ; _5 ?6 R" x/ G/ l7 }' I
try
/ Q' Q0 M" V! H x- i/ T{ 2 M5 _ @$ A0 `# ]- G% e
// Enter the path to a model file! # N* V8 s+ J, A% V/ j7 E( p
simple.LoadModel("C:\\Models\\Test.spp");
4 L. y7 r) ~% W} 4 @, Y& A$ ^( J/ H0 d
catch (e)
% q2 [' |# H: r9 A4 `{ ) B2 x \' ]! v% b8 f
WScript.Echo("Could not load Model!"); ' B) y0 k! \$ @, ]
WScript.Quit(); , u( _, m/ z6 J* Q8 w/ @
} ! `: T9 K, b' ?$ h& v
2 d# o- V" d, W' a/ l; ^0 a* C3 E
try
3 P9 x5 A' q0 |- L& H1 ]6 B{
- M# }1 R- a# {. a% I' L3 x simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { / E2 d6 V0 X( \* [3 o7 {) O, \ T
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); : {9 }# X4 R, b7 J% d
if (r == vbCancel) 3 t( B) B. `3 V0 B4 X. }9 o/ J
{
' a: a. J- E2 _6 z$ f: S1 l+ S& m simple.CloseModel();
% h2 n" v4 o' A: [* U3 @" K WScript.Quit(); , u( a9 i6 W4 h* c7 k
}
+ [- M( \2 _$ G& w3 F; ]* }& E} % C( n8 T: l) e( C% h1 ~ R' S
, Y- l6 ^, A; }5 U Bsimple.StartSimulation(".Models.Frame.EventController");
* G3 X* G. s, x' \! {
0 }. y9 j( [2 m. @; e4 Eif (simple.IsSimulationRunning())
9 T* _* e* @1 P WScript.Echo("Simulation is running!");
! v& K" U+ i3 p y2 e* P
! x' j A! s* R// Wait until simulation is finished
0 L9 v) P" O: M& }2 Q; U% N; Q" j5 ^while (!Finished) WScript.Sleep(2000);
5 `2 A) M6 |2 Y% V# ] , T1 b/ }, [9 V8 v5 N
simple.CloseModel();
; L% q" G& l% R4 i& Usimple.Quit();
+ j3 R* a# F3 R6 y2 e2 LWScript.Quit(); * |: h9 K8 U1 h* E; t5 a
/ T( k1 ?: X" q6 X5 c) k
- _# B( ?8 d- pfunction RemoteControl_SimulationFinished() - c$ |0 A* t" h; _) W( m2 m2 V! H, q
{
" U1 T* ]& O/ V, O, u' h WScript.Echo("Simulation Finished!"); |