Example of a JScript $ j5 p F/ x) E; x
var vbOKCancel = 1; ( W. b: e: j8 L# d V1 I
var vbCancel = 2;
( p. I% {" C7 h* o& hvar vbInformation = 64; ) p1 v5 s% i! P2 a w5 j
var Finished=false; 6 z/ p+ q8 f+ Z( L
% }; F F& b+ x' S+ V
var WSHShell = new ActiveXObject("WScript.Shell"); 0 l9 ]7 p1 T: x% I
. X" y2 G+ ^5 H0 G) ?. _
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
' x# I, i5 E* P( M% j" u- g9 S 0 s0 w# I% {7 T$ h5 {
simple.SetLicenseType("Runtime"); 4 B& |) j, u& o- N; d/ y; q
, J2 C- @: |; m" Z* p6 Q
try
3 e: p7 i. C4 q2 @' L( }' C5 z{ , M1 I9 j% ?2 R# m) C
// Enter the path to a model file!
' J6 w1 |% Q, v$ k, p. a simple.LoadModel("C:\\Models\\Test.spp"); * \$ l4 a# }) @) `
} ) E6 B3 ^. v6 V+ F) X
catch (e)
$ E7 T. w% b1 S. q{
x( n- ?2 l' o3 e- ^ WScript.Echo("Could not load Model!"); 4 Y9 _ Y( p) @6 ?2 j2 b3 b1 A
WScript.Quit();
8 Y# I) ?' a* ^4 B$ [- j8 |}
) k g$ H9 Z- T, C/ U
. z9 X7 K( _0 b* [try
0 o- w$ T0 ], f- _{
; _4 {* E; S# @9 G simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
H! L6 I/ V6 X' g0 O r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); # B/ X" z$ \( o# W8 y. n) [
if (r == vbCancel)
+ Y3 o: `" c2 G* \4 x' d6 M, a {
% l' f- X+ e# z2 i! U. F simple.CloseModel();
+ p+ l' a+ ?# m. m" E WScript.Quit(); : _# t7 v' S6 a6 A/ ], X5 B( }% v
}
" u) G: |- U: `4 W( V+ |} / f4 A% E: h9 P" ?
5 ?0 [- }, @2 ` E! R
simple.StartSimulation(".Models.Frame.EventController"); ; O0 C. [% y+ d. _, N
6 K" M1 K9 @/ S; H3 Nif (simple.IsSimulationRunning())
4 U s) Y8 x0 ~+ Y WScript.Echo("Simulation is running!"); ' [: {& W, C; L5 j, `- B
, P6 W3 m8 ?2 K: X4 G
// Wait until simulation is finished
% j$ }# `% x L5 u% lwhile (!Finished) WScript.Sleep(2000); 6 d0 I; D" i. e. o& a- m' p3 ~
& e/ S0 E* v3 p' K5 W, U5 jsimple.CloseModel();
- W% a* @# m5 V3 d9 I _) ^simple.Quit(); ! i6 k; Q$ ~( a
WScript.Quit();
0 D2 t, [. h' e1 I% x3 [5 A3 k9 d - u$ M* W: W2 T+ d6 J
- @* x& e2 [$ d( K% F& k$ M
function RemoteControl_SimulationFinished() % P! M3 n ?1 _1 p* ~, B2 I* G
{
; [ X$ k6 U3 F' A WScript.Echo("Simulation Finished!"); |