Example of a JScript
# E% W0 k" X/ V6 S" k; zvar vbOKCancel = 1;
1 F' k+ ^/ R' {/ Nvar vbCancel = 2; ! y% z! w2 Z+ m: k
var vbInformation = 64;
8 [6 ?- n( r2 O3 k( R" ivar Finished=false;
: i* C+ ~ J8 O
1 J; u6 H4 s m2 Z4 j: pvar WSHShell = new ActiveXObject("WScript.Shell");
; _1 y/ L3 j8 V& Z6 v* w U4 d
$ T- F- B% u- W7 N, p/ y( Vvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); * ], r$ l; j5 E5 d4 x( X
# S8 C3 X8 x _) W p9 I. p$ Xsimple.SetLicenseType("Runtime");
! C- b- _* i# J# o
5 L4 a1 \6 l) `. V6 C& \try
( t7 I, u) Y6 h" e{ 6 e A- s+ Z& q8 w% i% A% d
// Enter the path to a model file! 1 M) ~0 X2 ~- J9 x' J
simple.LoadModel("C:\\Models\\Test.spp");
, N% \2 y4 g1 W3 l/ B, Y} ; V8 I/ A& u- v" V/ ?8 h0 q9 ]# M
catch (e)
* X2 [6 W6 Y) H{
$ [1 K+ r6 S! o WScript.Echo("Could not load Model!"); 2 h$ M0 r3 \* i5 t9 N o( M) p+ H
WScript.Quit(); % Q" a* p* U% H- @
} ) n6 ]$ ^9 B" Y3 Y+ w
+ X+ w# \3 |8 V. e
try % C7 r! C2 u Z9 V. F) V7 h2 i
{
8 t( j4 _* o4 W2 C simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
; h5 E* V# B0 s, w% N( ?! j r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); & t l+ u6 G) w: H/ n- i6 d9 r
if (r == vbCancel)
8 L9 d) z' ` f4 m) n0 c! {8 D { , M9 q: C% w. x) w3 ~
simple.CloseModel(); 0 a d8 M& I2 _3 g
WScript.Quit(); + k" a/ V) c$ g2 ?
}
4 K; S* Z- ]6 O) E0 r}
_6 f9 D! s: s _2 A 0 E" N( X6 {/ i: \- S5 m* x
simple.StartSimulation(".Models.Frame.EventController"); 6 T) W5 {, U, @5 _& `
5 q4 h: i& e+ | z3 x1 B. cif (simple.IsSimulationRunning()) ; h7 r0 I0 ?0 e
WScript.Echo("Simulation is running!"); 8 {4 ~; \& L- y) |' L3 ^9 }
" h2 N+ o j- I6 K/ z& `0 s& _
// Wait until simulation is finished
- N- m: r; K2 G" _4 x! nwhile (!Finished) WScript.Sleep(2000);
( u) }" f+ R# W$ |1 c+ W' O
/ x3 r, |+ w1 b$ f% U, q Fsimple.CloseModel();
( y/ u$ w/ N8 \8 A0 u: ssimple.Quit(); $ I9 C6 o* M# u- W ~1 f2 g
WScript.Quit(); ( b8 Z5 ]& H/ Y; O* G* a! m! [
* `9 @0 F8 P1 J. T! n" {
3 A% @' T( [' Wfunction RemoteControl_SimulationFinished() 0 Y t% X" D4 T O8 H- B
{
* a U3 i; p& h. P& c WScript.Echo("Simulation Finished!"); |