Example of a JScript
) Z# x# v: W1 _& U* r3 ~5 \var vbOKCancel = 1;
, e5 T/ _ c; |* O2 {5 K" Svar vbCancel = 2; 1 J2 s* y3 @2 u, L
var vbInformation = 64;
5 D1 e2 i7 q8 S) Svar Finished=false; 8 n- z$ O# ?, C
0 Y% T' C3 g1 |! bvar WSHShell = new ActiveXObject("WScript.Shell");
3 L- Q4 d* ~4 L ( X. j" S9 l& M7 v9 W @4 F* c% s
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
5 |0 }3 K# P3 `% I
7 i, ?2 b( D. N+ Y1 g) {simple.SetLicenseType("Runtime");
/ B# h, k* ?: B6 r5 k ! r& m8 r( c% P5 }; p: a4 J
try 4 \$ a4 E9 h- N/ B6 E
{
% w" s- v4 E% x* V // Enter the path to a model file! * W5 _: S/ F- d) ^
simple.LoadModel("C:\\Models\\Test.spp");
6 }/ l* } e* H2 ]} ' W$ ?2 d/ I" N, P8 f
catch (e) 4 J) o( {: q! Y# f
{ ' M: i" N/ a7 L1 y
WScript.Echo("Could not load Model!"); ! U+ S) f2 t$ y& }+ i! x3 L
WScript.Quit(); # U) i6 B0 @# F7 }% `9 s) p
}
; Y0 g; ]2 P4 G* P! _6 ` ; f. a7 u9 ?) ?4 J1 b- I
try 5 j1 F# k& S! k/ @* e
{
5 Y" T9 \; S8 e/ l$ l simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { ! U2 }' ^3 A. H9 f- B, o b7 G
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
& g: K$ n, ]/ }! w" { if (r == vbCancel)
9 O, c; e4 l- q3 T s& } {
( E, U2 ]$ O, y2 p% i simple.CloseModel(); 0 p8 T( J9 i# K% R- A* i
WScript.Quit();
7 `! J1 G2 M: F f) _1 i8 B! w1 U7 s } * T) g0 P3 Q" K* b
} 1 _1 P1 u) J* @
) V6 \- A6 ^ I3 K! T5 U9 e5 {( fsimple.StartSimulation(".Models.Frame.EventController");
3 Z5 p1 H& x/ g6 f) i$ M
# Q! M8 s. b" g+ a" O4 [; H, ^) Pif (simple.IsSimulationRunning()) ( f) s; b% l! G& K
WScript.Echo("Simulation is running!"); 1 U9 { k4 i, _
C# c- _1 g3 v// Wait until simulation is finished
' B( @5 P% s& S! G" S& r( q, Z& |& Owhile (!Finished) WScript.Sleep(2000);
) L- I7 B* t* A) Y7 P0 \: c; k; Q, B5 b . H3 F3 @4 _7 y- z: P4 r* O0 d
simple.CloseModel();
. m [) {8 C8 Z7 L. w6 Ssimple.Quit(); 0 D% R0 i, _0 |3 v
WScript.Quit(); ( Z; Y) z( x7 R+ M! U, I& n
' _! l' N0 M2 w" j. l3 |" A) f
& _3 Q8 _* }/ B- Q( ifunction RemoteControl_SimulationFinished() , P+ W/ P9 p" j( Q9 K) v4 @
{
- J% g* _! u8 F. d7 S& G WScript.Echo("Simulation Finished!"); |