Example of a JScript
1 ]2 e8 \+ ^# c& D4 q3 w6 rvar vbOKCancel = 1;
* h* R2 n3 x# Y1 M$ f: V& Rvar vbCancel = 2;
- O$ ^* n* n! ^3 A5 ~6 V Tvar vbInformation = 64; $ \) u+ m: k' D6 [% q
var Finished=false; . o* k3 A; l- B. t* J4 i
( D# h8 B2 f% V3 v# y
var WSHShell = new ActiveXObject("WScript.Shell");
6 Y% L3 Q3 c0 Y ; K w8 n! |( l
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
# G/ g# P9 F: L% P- h: ^, L
$ G% D; o: S: A3 qsimple.SetLicenseType("Runtime");
7 n# k% H" E. o5 S1 [# h$ } - t; b4 L5 p6 Y" M2 H; B0 a
try / K+ h1 S0 |& S
{ $ l3 T6 n$ f+ ^6 a5 d
// Enter the path to a model file! 6 X: Y$ Q- Q& I" h. ]( j8 v
simple.LoadModel("C:\\Models\\Test.spp"); ) J5 G# {# i; d* [: m8 |
} 9 B; Q1 e5 u d
catch (e)
" T: e+ ]/ R6 [) T8 @% x{
# |+ a/ T6 `& J5 d% f- ~" s WScript.Echo("Could not load Model!"); 6 Z$ }# e0 N& I) K, X
WScript.Quit();
$ e& F) s) x2 s+ @/ E9 g; x( P}
7 C9 u6 Q; C' `7 O9 V4 E
0 v ?% v6 H1 \4 L0 o7 htry
6 h. k {: p0 Z0 u2 p! A L{ T& Q5 c4 q* s8 ^* H. t l
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ; O- i0 o! v( M8 x& ?
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); `' i q$ G8 |1 j1 `2 \9 x
if (r == vbCancel) 2 g& l0 U7 z3 V" Y! F& |
{
2 c& i& U: ~4 R% @% ` simple.CloseModel(); 6 A- G: R+ Q6 o" @- {9 T- [' T
WScript.Quit();
/ O5 h6 G% z5 d3 P } ' [# O) v5 U' b; Y5 S4 }
} 8 @7 }' B# f( X- s
/ I# y5 m, s: p
simple.StartSimulation(".Models.Frame.EventController");
8 Y9 J4 n/ K( F$ x) Z B
! o# ^3 E$ U9 x+ eif (simple.IsSimulationRunning()) 8 C* L- P9 _# M3 y
WScript.Echo("Simulation is running!");
& g; t/ {2 G( b7 w- C1 n" V$ S4 d
7 l# z, k/ d& Z G0 |! }3 ?9 c// Wait until simulation is finished
) ?5 f1 H# `% g3 F# j+ Lwhile (!Finished) WScript.Sleep(2000);
# E) u, j3 T( G. s: O! P. ]
; A/ o& w1 L+ N- k: v9 q Isimple.CloseModel(); 1 \$ W0 x! \2 p
simple.Quit();
7 Y) J% o1 g, B7 E2 m7 A- \WScript.Quit(); 0 ^* }% P6 p2 ?! l% ` W
9 i9 s7 \& f7 g
( T! Y' K8 o6 U6 }% lfunction RemoteControl_SimulationFinished() - V" l2 Q$ B% U& i J% {1 l
{ : U5 K# Q* F5 d: f/ B
WScript.Echo("Simulation Finished!"); |