Example of a JScript 4 \) B/ f4 F/ w6 l) _
var vbOKCancel = 1; # [* m4 V0 u+ |4 I! ?
var vbCancel = 2;
7 v' X, y# {# `1 rvar vbInformation = 64;
# A0 i) |& S! K, o0 {# s, zvar Finished=false; 4 M7 `7 J( l ]- v( [; Z( @( N. j
* t# a4 H+ `) p) u3 Pvar WSHShell = new ActiveXObject("WScript.Shell");
( j$ ~2 Q0 ?9 v* A$ `4 L l4 e) [ & ?5 e9 C# n9 V* ~+ x8 Z
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); . d% p7 Q" [6 R% r
( F: R' J' \1 q/ k5 R
simple.SetLicenseType("Runtime");
: w( K ]/ v0 ]' }% ~# g 4 C( ?# d1 }& J2 F% t: Q
try 3 @: }) ^& i+ \
{ . h" c$ C4 l( F+ Z0 u) U
// Enter the path to a model file!
* l2 H/ r$ l, u; e1 a( I simple.LoadModel("C:\\Models\\Test.spp"); 4 J* ?% g; f4 ?. p3 e g
}
2 o n2 T) m) `- S& S+ b/ s! c4 W6 r/ Y' fcatch (e)
& G( k1 P/ ~1 I0 l$ ~- T" A+ N4 Y{
$ c) R7 A0 o4 ? WScript.Echo("Could not load Model!");
' k. D+ ?' ]5 r2 J WScript.Quit();
, x \% c+ M2 j- \} 8 e9 N; K; E5 o+ C- p4 z7 s
4 V/ c& {. {" e3 l. `. }( ?) Z
try
# {" A) U+ o1 @. ^5 E{
$ a* C2 p9 |0 y! A simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
3 x, B" X% b# F. X2 L% C* ~( ^ r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 7 Y' @) V+ J! a$ y& x* O, Q- R
if (r == vbCancel) 5 _' V C @$ }( c- \
{ + s" ?: J1 a7 c& H! }3 s
simple.CloseModel();
7 i7 V! [" ~1 Z4 I9 R+ [ WScript.Quit(); 7 J4 B) G( I4 q3 |+ ?8 L( f
} ! v! S1 ]3 h% b6 r
} " |% g1 |& w- ^% ^/ f/ I. w
+ F; {9 O. D" `; q( O+ L8 ^$ u
simple.StartSimulation(".Models.Frame.EventController");
7 d) `3 b& o" Z$ C+ G5 F( A+ n: F 9 q; U7 B+ S7 b; u1 K$ ~) y
if (simple.IsSimulationRunning())
9 y( S' d$ ~1 f6 e3 ^. A) U3 I WScript.Echo("Simulation is running!"); . a6 c& Y# y0 Z* o- T
; K# b h. c. O+ \ k
// Wait until simulation is finished
& D1 h. o$ u) ?+ @4 i' o) b, h1 q5 Bwhile (!Finished) WScript.Sleep(2000); ; j, e9 @/ a4 @4 V, C
$ v9 W+ V* W: e7 o5 wsimple.CloseModel();
) e& {6 k. M0 p V( ^; ^% N bsimple.Quit(); - J3 o$ S9 I" Q1 Q1 O9 a' C
WScript.Quit(); 9 w. S) d) J6 ~- o9 ]& C
6 e+ y! C0 U# U/ Y' K7 ]) f- F
) e4 W3 ?' D) K. a9 zfunction RemoteControl_SimulationFinished() 5 i$ T& k8 N1 {! N
{ 9 I% @$ T/ Y, h! h W+ k% ]* o- c
WScript.Echo("Simulation Finished!"); |