Example of a JScript $ M: s3 L% H5 K; q/ D# m
var vbOKCancel = 1;
0 g, t' M# V7 E# zvar vbCancel = 2; * D7 J5 S% B* ]+ p9 O
var vbInformation = 64; ! t( {2 C" x' U' O4 [7 V' f
var Finished=false;
4 M% W+ Q' Z: G( h! [6 y. ^ / N9 n, U1 q' }
var WSHShell = new ActiveXObject("WScript.Shell");
) a4 b9 O- x) u& K& K
" ^& `* m X7 o8 x8 R; X/ Lvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
. \7 y( R6 q$ F! P 9 X( N0 @4 R' a
simple.SetLicenseType("Runtime"); : r& G8 ^0 H5 a u; ^0 Y- a
* u$ F1 R l, }) xtry ' X" s0 J( f: m0 f1 F
{ $ @4 d. n7 z8 a% a Y* r; Q T$ g
// Enter the path to a model file!
% u( R R4 Q* Z' a0 | simple.LoadModel("C:\\Models\\Test.spp");
$ h$ T& E' l( Z3 I c% N}
8 ` L" W" j, _, l0 Icatch (e) , [% t! X, P! y( F
{
' W4 s4 k$ t5 v' l+ V! ?& h( m WScript.Echo("Could not load Model!");
* h2 c9 Q3 A+ y0 i. ?/ @ WScript.Quit(); / M( | C6 Z: W0 {
} 3 y2 N8 f1 k4 ?
2 G5 C* X& x* _/ v0 Y
try . W! U# a- V/ t& k
{
+ L5 R) i( ~ {. a+ z) h3 T simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 2 R7 W2 P, v7 H: F: x" X8 G
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
+ i" u/ g5 f8 U6 m if (r == vbCancel)
/ @+ u$ V7 }+ m* E+ L% `) X { # g) C# I" `, n" A% @7 u5 G
simple.CloseModel(); 9 r3 s d. x) ^2 I( \" t8 A4 u
WScript.Quit(); * Z$ y" L# h. n$ m/ N3 M
} & ?8 ]. P) ]7 S7 A) k% m
} 5 d" q6 [0 |% b# ?5 }
. C& K5 {. W H3 n; B x
simple.StartSimulation(".Models.Frame.EventController"); # `4 A- s- D7 \) i. e! q
: E# J0 t. U) G* F! R
if (simple.IsSimulationRunning()) ' C' d4 T! p( ]5 x6 f
WScript.Echo("Simulation is running!");
f I# `- u$ B0 @0 A 7 c4 C8 q f+ K
// Wait until simulation is finished
9 U+ t% L4 ?* w$ J% ]# G6 d5 iwhile (!Finished) WScript.Sleep(2000);
: v# \2 L" |- F! t; M. {2 t* P { T$ i. n+ D+ [* w" W
simple.CloseModel();
8 T- L2 |! t0 Ksimple.Quit(); $ A+ S2 S. m$ O; O* R
WScript.Quit(); / T3 m0 ?$ O# v) K) X$ c5 x
+ S0 Q8 P# }4 p& Y( s) e
# O/ i+ l8 S+ f" S) n% |# a; ofunction RemoteControl_SimulationFinished()
9 B7 T) O1 R; S. t7 o" N{ : d! G7 B# Y9 W; {. M3 _
WScript.Echo("Simulation Finished!"); |