Example of a JScript + m% {6 N7 u( F2 o4 q
var vbOKCancel = 1;
: ]( _5 o. }, p& w, Q2 xvar vbCancel = 2; $ J c. A+ [5 C$ l
var vbInformation = 64; : d& @: q8 ?# g
var Finished=false; * p4 L' \4 m% C7 _
- o4 |9 j7 ~8 R3 e, m% g8 |7 e* Y
var WSHShell = new ActiveXObject("WScript.Shell");
) [. t, a( z) L6 i" U; s1 _ 1 |- j& J1 J0 D2 V7 U G
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); $ \0 \3 P0 B' D+ R. U
3 T0 ^9 s4 _- {9 {* W% f# Q
simple.SetLicenseType("Runtime"); * v' L4 n$ O. Y k+ }; ?
s5 J4 V3 w2 U, E- [try
, }; s4 V/ M: b# T: K M5 m{ 5 D) E; r7 i4 w2 c
// Enter the path to a model file! 8 C% ]/ `0 Q$ S# h
simple.LoadModel("C:\\Models\\Test.spp"); 4 j) y2 k$ }7 e" e
} - {! @$ U& p2 J: V( m I3 d
catch (e) ! Z+ w( _/ j7 u7 S: @' M
{ . j5 z* k' l, G' r
WScript.Echo("Could not load Model!");
* K# g7 S" B) T% \. @ WScript.Quit();
: Z9 }7 c6 U8 r( S5 B. Z! b}
- C8 Y. x% S& b/ p2 ?8 O
# w- s, e5 g& e P& Htry ; F: G0 h5 J$ ~; @5 ~
{ / y4 m$ L, e- E8 h8 U8 S& c# B
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
. g3 c8 {3 A4 P/ N; m i r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); - Y5 @( ?" Q& F1 @" X9 l
if (r == vbCancel) $ }+ u2 m8 Z* m% t
{ + O4 q& A. ~5 q, L, m' t
simple.CloseModel(); ) B; j( Z; z& V( r. V: E
WScript.Quit();
7 z; \; c6 Z5 S2 l+ t% o6 r }
, m9 a/ x. q1 }: m+ r4 D# a% T+ D}
7 r/ v. C: w; e# `# l M$ G& e' ~
, W$ n+ \$ |7 ~simple.StartSimulation(".Models.Frame.EventController"); ( _1 {) h/ H8 x: V. d4 S
0 a* o: ?1 W4 tif (simple.IsSimulationRunning()) 7 I( ^; P; h4 x& z3 D: E
WScript.Echo("Simulation is running!"); 4 Q. ~7 t4 C2 ]
( y& ^) M/ x9 D5 b/ U/ T/ e t V// Wait until simulation is finished
) ?6 m9 [( `/ V8 jwhile (!Finished) WScript.Sleep(2000);
$ T; V0 j. ]8 o7 Y
8 F' `* s; o* {8 y! Asimple.CloseModel();
2 P) J4 }$ j7 T# _( U8 f+ f0 j) ^simple.Quit(); ) l6 l" m6 w$ [, ]
WScript.Quit();
: j1 Z; X, ^/ E, [) g " P) ^% j4 t! L
' h* x! j1 j* ]- ~$ S; {$ Kfunction RemoteControl_SimulationFinished()
# N! k" k9 q# G# P- A, e{
9 K" M9 r1 T5 K2 Q1 O8 J WScript.Echo("Simulation Finished!"); |