Example of a JScript % ]' u$ D- j% q; e) C1 E
var vbOKCancel = 1;
& I# d. u% J5 j: }& Hvar vbCancel = 2;
& v/ ?" z" [) [* f/ Hvar vbInformation = 64; & j; X. s9 D- v; ]
var Finished=false;
1 Y% n4 u$ k e# D e% h( d : e8 P2 Y8 m, P3 N5 F; A
var WSHShell = new ActiveXObject("WScript.Shell"); * a* E# T6 t* O
3 k+ a& [; @3 y7 q$ k3 o1 t
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
9 D* _2 r3 ^4 `( j5 ?
3 W) ]4 b' J1 i# V" Asimple.SetLicenseType("Runtime");
: l3 m# _, w9 y" z& @% ~ ( R( X- U; [( E7 J! W# w
try 8 _4 Y7 h0 P- l' S, V0 O7 A5 q6 z
{ $ @/ w( Y' C1 q; ^' @$ t( B' V+ K
// Enter the path to a model file! 0 n9 C8 ?- ?% F7 ]9 J* q
simple.LoadModel("C:\\Models\\Test.spp");
3 Z2 m( s* P! m+ S0 [: W* S} 0 d) d# y4 {7 D! r _8 h! ?& d, Q
catch (e)
. O' k/ O1 u4 E% |! u) C0 e{
* T& H- o$ _9 j% G8 z' V WScript.Echo("Could not load Model!");
/ I+ ]; q. E8 q+ z3 d1 J WScript.Quit(); : p8 {& [3 N2 d3 y* D
}
4 e" n& v" i- S* _ $ I& Q( t0 U2 ^* i
try - J. c K% S+ U( Q& Q
{
: H3 \+ A, O/ g8 m1 { simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
5 N. h" G% O! F r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
2 \1 @6 X7 \2 x/ D5 }7 z if (r == vbCancel) 5 G; |' B" r$ o) j+ S8 h
{
5 p0 y$ ~1 X# f& B& m& b simple.CloseModel();
* p, C2 v4 ~! B# e WScript.Quit();
" u. Y( Y0 y: c% D! C# Y }
' [& M$ V& o7 p* j% U} ; P8 P8 I& C' y5 p- s% z- f
& s0 ^# n6 g$ p9 i
simple.StartSimulation(".Models.Frame.EventController");
9 |! j' d4 g7 a e5 b! l+ z+ L 6 _4 t9 I# p6 u
if (simple.IsSimulationRunning())
, y: M5 o7 ~6 ]2 K K3 |0 V WScript.Echo("Simulation is running!");
@7 s) {" _. h; k O( V$ P: j0 }3 Z2 f
// Wait until simulation is finished ; Q O" W8 t/ s7 _' V" o9 A- Y) y/ n
while (!Finished) WScript.Sleep(2000); 6 t' e. f5 t0 C/ G. E
8 T/ g4 n8 g6 n4 }9 P, zsimple.CloseModel();
/ L& w! B9 }( F" p& [+ t. f- isimple.Quit();
$ W: N/ F8 ~9 O' B- F* lWScript.Quit(); # F( | x' ]2 r3 h
8 w# [: N* t, B% _7 @; M9 O9 ?
8 H0 v3 ^; o6 ^" Ffunction RemoteControl_SimulationFinished() $ O( h+ L1 n1 g! [) s; r
{
# X! o7 K8 k% c2 p6 u# O; L {+ B9 _% T WScript.Echo("Simulation Finished!"); |