Example of a JScript
8 K9 e9 V: j0 N i! m' avar vbOKCancel = 1;
4 f r3 |# L- p( xvar vbCancel = 2;
7 D7 ~3 N% U* C& ?% u |var vbInformation = 64; # D, O9 B+ z: F; d. c* X
var Finished=false; & I. `+ U% v, _0 ~6 I; o# V
+ X- U3 \0 f' X0 L0 y! D+ x9 t' ^' z5 V
var WSHShell = new ActiveXObject("WScript.Shell");
K5 s. V. j0 V; N$ l$ ?5 X# a! t
}1 E# z) e% j$ ~' H+ u5 r* c7 |var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
0 w3 S: Y) H: P* o7 i 1 e2 _) V* I3 P# L
simple.SetLicenseType("Runtime");
' `/ ?2 \& N2 h/ K7 M* D * u5 e4 c( U; Z" K* k3 |1 ?
try {, X! ~8 @/ }7 b5 f6 Z
{ ' `# L' j2 ^/ R! T
// Enter the path to a model file!
) ]1 |/ Q6 k4 J simple.LoadModel("C:\\Models\\Test.spp");
9 {3 |( e8 }5 W. |& D( b} ; G3 M, J6 h+ Y) v- U
catch (e) : W# ^8 Q$ m7 _6 d
{
0 @0 s& n$ f9 g WScript.Echo("Could not load Model!"); / U! u" x# u+ n* a
WScript.Quit(); 2 w x8 m2 m K9 o1 r
}
2 [( F% S1 p( o5 y' b
2 q4 M0 I& w0 u+ vtry ; a+ Q7 t) \$ z" @7 c. y0 n
{ 7 U/ M, z) p3 N1 S
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { : ~4 Q1 c" x& T
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 3 L! H6 g" t4 t( z
if (r == vbCancel)
; P/ x5 X8 t/ N! F( W( d0 q) X { 0 Q" n' K5 i4 i
simple.CloseModel(); 7 m+ O5 w; b" m. k" O
WScript.Quit();
9 @1 r- T4 [5 q; B }
. A2 [/ ?6 G' a} / D$ S3 [" b8 d* C6 O
( b6 {6 N5 w" y& t/ ~8 f- t' g
simple.StartSimulation(".Models.Frame.EventController"); % N& J1 S6 O+ m( R5 @, V* {5 p
$ m& ]+ G5 k; M0 G& {( r
if (simple.IsSimulationRunning()) 6 R: y: y$ `/ h, E
WScript.Echo("Simulation is running!");
) n/ p6 E5 U" H4 g _
9 Q! {; v5 x) ]2 T) |// Wait until simulation is finished
' ~6 t- Q @* x; M! G/ vwhile (!Finished) WScript.Sleep(2000); 4 p, I( ]' O, E7 B# i( m6 S
O' z: f) C2 t( P* }4 t+ K
simple.CloseModel(); ' ?5 {% D0 {# E
simple.Quit(); # i) r7 x* u9 r7 Y+ V& P7 v1 ?
WScript.Quit();
0 i3 H/ d, K: L; l- ~" U8 r
/ J5 ?7 B6 e; `+ a6 K' L3 Y4 q
6 Y3 v2 b; g. j+ l5 R, vfunction RemoteControl_SimulationFinished()
6 ^$ |/ i+ s/ q4 [: _{ ! B! Q- H S- k3 p8 h! A6 [
WScript.Echo("Simulation Finished!"); |