Example of a JScript $ R, s4 e( K5 J
var vbOKCancel = 1; ; @: H7 f0 K$ B Y6 w* B+ ^% S
var vbCancel = 2;
3 h, j) B$ ?& ]( w. }. F" O! Lvar vbInformation = 64;
+ d& V( j) ~4 F' f/ dvar Finished=false;
' H: t' r! |4 ~0 i9 Z5 E% @ $ V6 D0 F6 e9 R+ _1 ?
var WSHShell = new ActiveXObject("WScript.Shell"); ( E% ^2 `5 M% V# C
3 _% q. y7 {+ B( L( D/ ivar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
2 M* [8 j1 p+ J+ S/ I* X" L8 f: \3 L
+ ~$ o$ a T8 ^9 y# Z/ hsimple.SetLicenseType("Runtime"); 8 h4 e5 I1 H5 l3 p9 }" Y
. b6 j! I% i# H4 }7 ?; @% n: i* Q6 Y
try
# f. \% f& s: X# h( W2 ^. F{ - ?! u8 a. X1 I. w& s; R6 R/ `4 n
// Enter the path to a model file!
. _# E: M: C/ ~8 Z5 N0 ` simple.LoadModel("C:\\Models\\Test.spp");
0 j2 ~0 P, O) {+ {$ g4 Z}
5 b+ l6 O; v: rcatch (e)
$ l3 ]4 [% v7 l7 S+ s( q- Y{
; T6 q% M. [9 ]+ b WScript.Echo("Could not load Model!");
8 \9 s' ^. O. r# W" Y WScript.Quit(); % Q& B' D; C# V# p7 p& b$ ?% k, x
}
' \2 t/ r' T% l8 F1 z 5 y) g/ a: l6 M1 k: K2 b
try
' o$ Z) p1 @. p5 U5 L8 f+ z% @{ 8 Z/ ~' [8 N0 }) |
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { + c3 k8 J& j* q. Y
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); 5 d6 G( a1 \4 o) u3 V) q% q
if (r == vbCancel) 4 [7 |& }! h4 d% }
{
+ W/ J# S# L0 ]/ s5 _! ]/ H simple.CloseModel(); 9 {9 x H5 l2 _
WScript.Quit();
1 x$ `$ x* ]# \( r } . l5 R+ P1 Z7 ^, B
} e& t1 {# j% D+ Q/ b, Z
& i0 {6 O. h9 X* o& a1 L
simple.StartSimulation(".Models.Frame.EventController");
1 e2 V0 R A }- r* Q3 v ! c" y; S$ o E$ B: @: J5 n
if (simple.IsSimulationRunning())
6 N3 B S3 ^( Z6 P! F' m* j WScript.Echo("Simulation is running!");
% {' s5 ]2 g2 }2 h0 W % m0 q! |! \* y7 E1 ?9 v0 ^1 Y
// Wait until simulation is finished
8 M7 }# I# J; L& f0 k+ Z7 lwhile (!Finished) WScript.Sleep(2000); * K; C [( j5 C3 o, M. \9 w
$ g$ ? }) K; A9 J2 C
simple.CloseModel(); 9 @9 h) P6 w( G' P+ F
simple.Quit();
& K+ `# Z' P* N/ |2 @3 L8 mWScript.Quit(); * m) c* A T: Z) v7 t" r
# m3 X9 L; @ F3 _4 g6 b6 }" I
9 M6 x8 L9 j2 G! S& [& a& B0 ]" wfunction RemoteControl_SimulationFinished() 8 T# D! Q9 x$ Z# t$ D. }
{
O7 B; @& ^9 m6 v* ?( d0 W WScript.Echo("Simulation Finished!"); |