Example of a JScript + w7 E" Q, ]8 L
var vbOKCancel = 1;
/ Q( n) t' i) Tvar vbCancel = 2; " C: z$ k) Q9 B% P( \, d
var vbInformation = 64; ; r* ]; _# a" U1 s6 J2 G
var Finished=false; 6 F# V5 ?' x* M0 [
0 k; X1 K/ M- j( J r5 `var WSHShell = new ActiveXObject("WScript.Shell"); % T* e5 d2 m* F+ J! n% ?1 X
3 Q7 |4 o c( o% S) h
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
% e$ R6 R7 D% d9 { $ h6 r' f; h4 o" U% V8 T# u) q
simple.SetLicenseType("Runtime");
) \" ?% }& H2 k; N* g$ y8 R 6 ~/ `$ f! h2 u& w- R
try 2 D+ u- q( Q& A7 s
{ - g' {1 I2 o) b% P- i
// Enter the path to a model file! ! S: a2 f( E- H) N7 P
simple.LoadModel("C:\\Models\\Test.spp"); # z7 O) Z8 K9 u, |0 m
} / O$ C V3 t' j: ]2 l& E
catch (e) - ]; }+ _5 @# V4 D9 S! P0 @" z
{
; C3 U7 d! j; L5 I! P WScript.Echo("Could not load Model!");
7 }5 l7 y( _0 y6 G7 H8 i9 q4 l, [ WScript.Quit();
, F/ x8 i. |/ j6 E} % d8 g2 P$ \8 M- a" p
% u' U! p+ I* O3 k( G6 l+ |( u
try 8 E7 G( J D p C' ]; L4 v( Z8 V3 G
{
# a8 y# S6 F" e" l! b0 Q4 j simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
$ p' A2 _9 d; a) w/ N4 G! P r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); / { B2 w# d' ~8 [3 K. i
if (r == vbCancel) 7 H# \* W0 k8 H
{ 2 y, v# L% s( u5 C" ~6 d2 R) l
simple.CloseModel();
' h+ }# {0 K: M$ e, I: e3 K+ F WScript.Quit();
$ s. q8 R' T: Z+ A1 j. Z }
, u( f% {8 V7 B& h+ B2 f6 R} 2 } g7 k& ?% P. m4 g
6 h" Z* O7 w" I& o2 T) u' tsimple.StartSimulation(".Models.Frame.EventController"); 8 S6 u6 p- l# p; M
~1 c! n3 O9 b! ?8 b8 H+ G8 S- o- F
if (simple.IsSimulationRunning())
0 n* C, }% @' A7 K( c$ S" t1 X% Z WScript.Echo("Simulation is running!");
& z. L. ~3 D9 H6 X' P + j/ `4 Y4 k# k; A& r
// Wait until simulation is finished ; b. I8 F5 X. ]9 P- T+ \: J
while (!Finished) WScript.Sleep(2000);
2 q/ w9 E# L4 o6 Y. t/ z % e& L3 [3 Y* H
simple.CloseModel();
7 C$ L, a3 \) _simple.Quit(); $ o9 h8 K. i) b1 [
WScript.Quit();
6 C: n4 c1 z, a+ J
. \2 c( {( r$ d* U % n+ F$ i7 ^1 ~5 g5 E
function RemoteControl_SimulationFinished() 7 C7 |4 W J p
{
! l& f+ Y+ Q% L5 i7 U' Z6 Y/ ]; R! Q WScript.Echo("Simulation Finished!"); |