Example of a JScript 5 X" P: g" u' y' H7 B
var vbOKCancel = 1; * c: E; ?: |8 d! y9 p
var vbCancel = 2;
, U5 Q) i$ J# S* uvar vbInformation = 64;
; o$ \1 j* m% Y; J2 c2 O; ]var Finished=false; + o; m( S" U4 P- r( v
( I, i! s: O, V* b
var WSHShell = new ActiveXObject("WScript.Shell");
) X/ P0 x8 X2 W; i* J; S4 H& ~ ' i! u7 j! H- }! v& N8 F
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); + g& L, E s! V0 Y% v
0 v0 w! J8 J. U! {: J
simple.SetLicenseType("Runtime");
4 ?7 a/ B# X) j; v
Z7 c9 w( o1 v! F3 N7 v& ztry + P) U1 S. t9 r/ h7 w
{ ; f9 p2 l7 ]+ s
// Enter the path to a model file!
) g( L& q/ L" E! I9 { simple.LoadModel("C:\\Models\\Test.spp"); 4 b6 ]2 f0 \' d; e, u4 v
}
2 g6 A5 F' o+ P- |0 Wcatch (e) ( q* r- T# x$ I- U% P# k% Z
{ ( d, s% I$ g( [9 U$ |
WScript.Echo("Could not load Model!");
) z% B# V S* c WScript.Quit(); 9 |9 g" ]5 K; ]$ d; o
} / i% R2 w; K' S: B
$ q7 G7 b# E/ r& ?( Q; i; U8 X2 G
try $ s2 J) K- r M0 v b! r
{
+ N+ G4 K) q" a' r simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { 6 V M# E M% a! b7 A
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
/ r% W4 B6 q3 x% o$ y# u) i6 b/ _ if (r == vbCancel) + ^0 }- y7 x' k- B- E1 P
{ l5 g) r" y; Q; P4 h. y
simple.CloseModel(); 6 D- P' D* v4 [+ F Q' ^; N5 \
WScript.Quit();
: T, E9 Z( u9 b) [ } / F6 X- z" `+ f: i0 z
}
+ h. T1 Q: l0 y. M8 Z; k& `2 w
5 {) G6 S; Z7 D$ qsimple.StartSimulation(".Models.Frame.EventController");
f4 @3 C/ \4 t$ d& t/ T# } 9 c5 v$ k1 Z0 R1 V
if (simple.IsSimulationRunning())
2 k. n7 K( c/ Y. M" V; Z WScript.Echo("Simulation is running!"); ) I$ w+ r1 O9 S" J+ x6 C, @
5 q9 t8 I t6 u1 s" z! F3 y
// Wait until simulation is finished
: G" P8 v1 l9 l5 F. {while (!Finished) WScript.Sleep(2000);
7 K0 p4 i7 W% ~* _( _- m" J
% C! `8 d) Q: h$ U h5 Z1 \/ ^simple.CloseModel(); 7 W: @+ R( H+ I7 p7 J0 d# ~& E, Z
simple.Quit(); : z2 d( `1 L0 K" E+ ^' m* M
WScript.Quit();
& }/ l; [8 j9 Q7 A 0 K. \$ r( D$ }5 L' E' C9 N0 G! P
- U6 @% ~% P9 b$ {
function RemoteControl_SimulationFinished() 8 A. y5 f5 O+ d! {4 ^+ H9 g. ^& ^; E
{ % R8 K6 ^5 h: N% A
WScript.Echo("Simulation Finished!"); |